Hi Kans,
I'm back home and it turns out there was a simple bug--pretty easy to fix.
Here's the fast patch:
Go to library.php and go to around line 1727 and change the pattern there
to '/^(.+) \:\: (.+)?/m'. Or better yet, replace the whole BOLTtranslate
function:
function BOLTtranslate($text, $language='', $reverse=false) {
## THE TRANSLATION ENGINE IN BOLTWIRE FOR SWITCHING KEY PHRASES TO YOUR
CHOICE OF LANGUAGE OR BACK
if (function_exists(myBOLTtranslate)) return myBOLTtranslate($text,
$language, $reverse);
global $BOLTlanguage, $BOLTlanguageArray;
if ($language == '') $language = BOLTinit(BOLTconfig('language'),
$BOLTlanguage);
if ($language == '') return $text;
if (empty($BOLTlanguageArray[$language])) {
$content = strtolower(BOLTloadpage("site.language.$language"));
preg_match_all('/^(.+) \:\: (.+)?/m', $content, $matches);
$BOLTlanguageArray[$language] = array_combine($matches[1], $matches[2]);
}
$id = strtolower($text);
if ($reverse == true) $out = array_search($id,
$BOLTlanguageArray[$language]);
else $out = $BOLTlanguageArray[$language][$id];
if ($out == '') return $text;
if ($text == strtoupper($text)) return strtoupper($out); if ($text ==
ucfirst($text)) return ucfirst($out); if ($text == ucwords($text)) return
ucwords($out); return $out;
}
The main problem was the preg_match pattern. But you will notice I also
simplified the logic in the first section a bit. And I added a hook for
customized translation functions. Plus I fixed a glitch related to the new
capitalization scheme.
The new translation system works just a bit different than before in an
effort to make the translation file case insensitive. That is, you no
longer need to have lines in the translation page for Save, SAVE and save.
They will all be translated and retain the correct capitalization. But--a
technical detail--the original must be all caps, have all the words start
with a capital letter or have the first letter only capitalized. If you try
to translate "Save some Page" it will come out all lowercase. A trade off
for case insensitivity. Anyway, this means future language files should be
easier to create and our current ones now all have redundant lines in them.
Of course with the customization hook you could revert to the prior
behavior pretty easy... :)
We'll see if this case insensitivity causes any problems with languages
like chinese. Would appreciate any foreign language users to give feedback
that all the internationalizations are working ok...
The following things are automatically translated (assuming a match can be
found in the language file):
Form Buttons
Link Labels
++Text Within Double Plus Symbols++
Form Messages
To use a language file, copy it to site.languages.fr (for French), then set
"language: fr" in site.config. If you want users to set their own language
preferences, simply write a script in config.php that assigns $BOLTlanguage
to fr or de or es or whatever you want using whatever member criteria you
wish.
Cheers,
Dan
On Fri, Jun 13, 2014 at 9:22 AM, Kans <[email protected]> wrote:
> Ok, thank you very much , have a nice trip
> !!
>
>
> Dan於 2014年6月12日星期四UTC+8上午7時08分26秒寫道:
>>
>> Hello Kans,
>>
>> I don't use a language file on my site, so it is possible this was broken
>> in a recent upgrade, and you are the first to report this. I know I made
>> some modifications to how the translation system works--so we may just need
>> to update the documentation.
>>
>> Unfortunately, I am traveling at the moment and won't be able to get back
>> to my home computer and look at this for a couple days. I will check it as
>> soon as I can and get back to you. Just wanted to let you know I saw your
>> email!
>>
>> Cheers,
>> Dan
>>
>>
>> On Wed, Jun 11, 2014 at 5:51 PM, Kans <[email protected]> wrote:
>>
>>> I had try the following steps to change the system language:
>>>
>>> 1. add a page name is site.language.test, then copy the content to it
>>> from http://www.boltwire.com/index.php?p=site.language.zh-cn
>>> 2. edit site.config, set language to "language: test" then save it.
>>>
>>> but nothing to happen, is it wrong?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "BoltWire" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>>
>>> Visit this group at http://groups.google.com/group/boltwire.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "BoltWire" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/boltwire.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/boltwire.
For more options, visit https://groups.google.com/d/optout.