Project language file

46 views
Skip to first unread message

Artyom M

unread,
Dec 1, 2014, 1:43:34 AM12/1/14
to koala-fra...@googlegroups.com
Niko,

In my app some translations adds to trl.xml. After update this file was replaced by new (without my translations). 

Can I create a custom file with additional translations which will not be updated with the new version of kwf-lib?

Niko Sams

unread,
Dec 1, 2014, 2:23:27 AM12/1/14
to Koala Framework Dev

No, but the translations can be added to the upstream repo. Just create a pull request.

Niki

--
You received this message because you are subscribed to the Google Groups "Koala Framework Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to koala-framework...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Artyom M

unread,
Dec 2, 2014, 2:44:27 AM12/2/14
to koala-fra...@googlegroups.com
I mean my own translations that I use im my app. Not only to translate existing lines in trl.xml. 

Niko Sams

unread,
Dec 2, 2014, 12:38:15 PM12/2/14
to Koala Framework Dev
Let me explain:
there are two trl.xml:
- (1) youapp/trl.xml
- (2) kwf-lib/trl.xml

(2) is used for strings that are used inside kwf, masked by trlKwf()
(1) is used for strings taht are used in your app, masked by trl()

you can use trKwf() in your app code for strings that also exist in kwf - but only those.


- the language for (2) is always english
- the language for (1) is you config.ini setting webCodeLanguage

if you don't have multilanguage support in your app you don't need (1) at all


see also:


Niko

On Tue, Dec 2, 2014 at 8:44 AM, Artyom M <psycho...@gmail.com> wrote:
I mean my own translations that I use im my app. Not only to translate existing lines in trl.xml. 

--

Artyom M

unread,
Dec 11, 2014, 8:30:32 AM12/11/14
to koala-fra...@googlegroups.com
>No, but the translations can be added to the upstream repo. Just create a pull request.

Artyom M

unread,
Dec 14, 2014, 9:50:34 PM12/14/14
to koala-fra...@googlegroups.com
I'm also found trlKwfStatic function. How it works?

Has KWF a trlStatic function?

Artyom M

unread,
Dec 15, 2014, 12:26:38 AM12/15/14
to koala-fra...@googlegroups.com
>- the language for (2) is always english
No, language come from webCodeLanguage parameter. You mean (1)?

ID numeration in youapp/trl.xml comes from 1?

Now my app/trl.xml file contains:
<trl>
<text>
<en>Dictionaries</en>
<ru>Справочники</ru>
<id>1</id>
</text>
<text>
<en>Dictionary</en>
<ru>Справочник</ru>
<id>2</id>
</text>
</trl>

and trl('Dictionaries') don't return russian language value =(


Niko Sams

unread,
Dec 15, 2014, 7:40:39 AM12/15/14
to Koala Framework Dev
On Mon, Dec 15, 2014 at 3:50 AM, Artyom M <psycho...@gmail.com> wrote:
I'm also found trlKwfStatic function. How it works?

Has KWF a trlStatic function?
yes.

Niko Sams

unread,
Dec 15, 2014, 7:42:11 AM12/15/14
to Koala Framework Dev
On Mon, Dec 15, 2014 at 6:26 AM, Artyom M <psycho...@gmail.com> wrote:
>- the language for (2) is always english
No, language come from webCodeLanguage parameter. You mean (1)?
no, the language for kwf-lib.
 
ID numeration in youapp/trl.xml comes from 1?

Now my app/trl.xml file contains:
<trl>
<text>
<en>Dictionaries</en>
<ru>Справочники</ru>
<id>1</id>
</text>
<text>
<en>Dictionary</en>
<ru>Справочник</ru>
<id>2</id>
</text>
</trl>

and trl('Dictionaries') don't return russian language value =(

what's your webCodeLanguage in config?

Niko 

Artyom M

unread,
Dec 17, 2014, 8:14:24 AM12/17/14
to koala-fra...@googlegroups.com
>what's your webCodeLanguage in config?

webCodeLanguage = ru

Artyom M

unread,
Dec 18, 2014, 6:56:38 PM12/18/14
to koala-fra...@googlegroups.com
In kwf-app-demo I see using of fuction 'trl', but I don't see any app/trl.xml files. 
I don't understand how it works... 

Artyom M

unread,
Dec 18, 2014, 8:26:47 PM12/18/14
to koala-fra...@googlegroups.com
My app/trl.xml in kwf-app-demo:

<?xml version="1.0" encoding="utf-8"?>
<trl>
<text>
<en>Active</en>
<ru>Активен</ru>
<id>5000</id>
</text>
<text>
<en>Customers</en>
<ru>Покупатели</ru>
<id>5001</id>
</text>
</trl>

-------------------

config.ini:
webCodeLanguage = ru

all functions use 'trl' and result - IT NOT WORKS =)))

Niko Sams

unread,
Dec 19, 2014, 12:39:11 PM12/19/14
to Koala Framework Dev
ok, if webCodeLanguage = ru then you must code strings as ru:
trl('Покупатели')

the actually used language (target language) is defined by the currently logged in user.

some questions:
- do you need your app translated at all?
- does your user model have a language column? (in the kwf_users table)


Niko

--

Artyom M

unread,
Dec 20, 2014, 6:33:07 AM12/20/14
to koala-fra...@googlegroups.com
>ok, if webCodeLanguage = ru then you must code strings as ru:
>trl('Покупатели')
Strange logic....90% of project use trlKwf() in English to needed language by webCodeLanguage parameter, but trl() must be in selected language. Why? =)
I see two ways now:
1. Add all my app translates to kwf-lib/trl.xml and use trlKwf() func everywhere. Give me a problem with new versions of file and "composer update" command.
2. Or don't use trl at all and put in one language. Problem - no multilangual support.

>do you need your app translated at all?
Yes. I want RU and EN languages in project depending on the user.

>does your user model have a language column? (in the kwf_users table)
Yes, I have language column in kwf/user/users, but don't see how to change it in edit dialog =)

Niko Sams

unread,
Dec 21, 2014, 11:58:17 AM12/21/14
to Koala Framework Dev
If you use trlKwf: code in english
if you use trl: code in webCodeLanguage (ru in your case)

in your code you always should use trl()

If you prefer to use english in trl() calls - that's fine - just change webCodeLanguage to en

The point of why you can change that at all is to make it possible to develop an application
in it's main language (which most users are using) and translate it later.

Niko

--

Artyom M

unread,
Dec 21, 2014, 8:41:54 PM12/21/14
to koala-fra...@googlegroups.com
>If you prefer to use english in trl() calls - that's fine - just change webCodeLanguage to en
And my app change 90% strings to EN :D

If user enter to app with lang setting = EN - what he can see in trlKwf() output? EN or RU?
All I want is full RU and EN translations depending on user lang setting=)

Niko Sams

unread,
Dec 22, 2014, 1:34:20 PM12/22/14
to Koala Framework Dev
If user enter to app with lang setting = EN - what he can see in trlKwf() output? EN or RU?
All I want is full RU and EN translations depending on user lang setting=)
you'll get the string in the the user language.

doesn't it work correctly for you?

you can check the current target language using:
Kwf_Trl::getInstance()->getTargetLanguage()

Niko

Artyom M

unread,
Dec 23, 2014, 1:50:30 AM12/23/14
to koala-fra...@googlegroups.com
Multilang not working in Koala =((

What I did:
1. Change language column in kwf_users table to EN (directly in MySQL)
2. build, clear-cache, clear cache in browser etc
3. Nothing changed... trlKwf output is RU, trl output is RU

Niko Sams

unread,
Dec 23, 2014, 9:48:24 AM12/23/14
to Koala Framework Dev
what is
Kwf_Trl::getInstance()->getTargetLanguage()
returning?

and are us using 'en' in lowercase?

Niko

--

Artyom M

unread,
Dec 23, 2014, 6:35:39 PM12/23/14
to koala-fra...@googlegroups.com
>Kwf_Trl::getInstance()->getTargetLanguage()
'ru', but user in kwf_users has 'en'

>and are us using 'en' in lowercase?
'en' and 'ru' in lowercase

Artyom M

unread,
Dec 24, 2014, 2:12:41 AM12/24/14
to koala-fra...@googlegroups.com
Something strange with trl function.

$this->_form->add(new Kwf_Form_Field_Checkbox('status', trl('Выполнено')));

shows me

Аэропорты (another trl.xml value)... 
id numeration is right and starts from 1

I clear all cache...
How to fix?

Niko Sams

unread,
Dec 24, 2014, 3:24:45 AM12/24/14
to Koala Framework Dev
On Wed, Dec 24, 2014 at 12:35 AM, Artyom M <psycho...@gmail.com> wrote:
>Kwf_Trl::getInstance()->getTargetLanguage()
'ru', but user in kwf_users has 'en'
ah, ok. that explains it.
do you languages defined in config?
eg:
languages.en = English 
languages.ru = Russian

if that doesn't help please do further debugging in Kwf/Trl.php getTArgetLanguage

Niko

Niko Sams

unread,
Dec 24, 2014, 3:26:21 AM12/24/14
to Koala Framework Dev
how could that happen?

if you debug the trl output using d(trl('...'))
does that work correctly?

i suspect trl not being the problem here...

--

Artyom M

unread,
Dec 24, 2014, 9:15:57 AM12/24/14
to koala-fra...@googlegroups.com
>do you languages defined in config?
>eg:
>languages.en = English 
>languages.ru = Russian
Wow...works like charm! Thx, Niko! =)

Why there is no word about this in guide?

>how could that happen?
I don't know... In one place sometimes wrong value, sometimes right. 

>if you debug the trl output using d(trl('...'))
>does that work correctly?
No, wrong value =(

My trl.xml in attach. I try to use value with ID 33:
$this->_form->add(new Kwf_Form_Field_Checkbox('status', trl('Выполнено')));

but output is ID 11
trl.xml

Artyom M

unread,
Dec 25, 2014, 9:25:06 PM12/25/14
to koala-fra...@googlegroups.com
There are more and more errors with trl() and trlStatic() functions =(
Other values are shown.

Niko Sams

unread,
Dec 28, 2014, 4:04:59 PM12/28/14
to Koala Framework Dev
On Wed, Dec 24, 2014 at 3:15 PM, Artyom M <psycho...@gmail.com> wrote:
>do you languages defined in config?
>eg:
>languages.en = English 
>languages.ru = Russian
Wow...works like charm! Thx, Niko! =)
great!
true, I'll add that... 


>how could that happen?
I don't know... In one place sometimes wrong value, sometimes right. 

>if you debug the trl output using d(trl('...'))
>does that work correctly?
No, wrong value =(
what is your target language where it is not working?

Niko

Artyom M

unread,
Dec 28, 2014, 6:22:27 PM12/28/14
to koala-fra...@googlegroups.com
>what is your target language where it is not working?
WebCodeLanguage = ru

all trl() values also in RU... output is RU, but wrong (another) value.

Niko Sams

unread,
Dec 28, 2014, 6:26:57 PM12/28/14
to Koala Framework Dev

Ok, that should be relatively easy to debug as the should be returned as it is.

Could you try debugging that in kwf/trl.php?
Or u give me something where I can reproduce...

Niko

--

Artyom M

unread,
Dec 29, 2014, 2:47:49 AM12/29/14
to koala-fra...@googlegroups.com
Or u give me something where I can reproduce...
I use same trl.xml as in my app.

But it works good with same controllers =(
Huh...maybe I miss something in my app? 

Already in menu every time I see changing the value of trl() translation...trlKwf() works normal

Niko Sams

unread,
Dec 29, 2014, 10:08:54 AM12/29/14
to Koala Framework Dev
On Mon, Dec 29, 2014 at 8:47 AM, Artyom M <psycho...@gmail.com> wrote:
Or u give me something where I can reproduce...
I use same trl.xml as in my app.
ok, what do I have to do to see the problem?
 

But it works good with same controllers =(
Huh...maybe I miss something in my app? 
yes, something is not right here...

you could also test by:
- adding debug code in bootstrap.php right after Kwf_Setup::setUp():
p(Kwf_Trl::getInstance()->getTargetLanguage());
p(trl('Выполнено'));
exit;

Niko 

Artyom M

unread,
Dec 29, 2014, 6:45:41 PM12/29/14
to koala-fra...@googlegroups.com
>ok, what do I have to do to see the problem?
1. install setup\tasks.sql
2. Acl.php - line 23
tasks\TaskController - line 26

In my app this lines shows wrong, in testcase right values....

>you could also test by:
>- adding debug code in bootstrap.php right after Kwf_Setup::setUp():
>p(Kwf_Trl::getInstance()->getTargetLanguage());
>p(trl('Выполнено'));
>exit;

Omg...abracadabra value :D

string(2) "ru"
C:\OpenServer\domains\aviashelf\bootstrap.php:11
string(18) "а б б€аОаПаОб€б‚б‹"
C:\OpenServer\domains\aviashelf\bootstrap.php:12

Artyom M

unread,
Dec 29, 2014, 8:40:28 PM12/29/14
to koala-fra...@googlegroups.com
It was the problem with encoding.
Value is wrong as usual.

Artyom M

unread,
Dec 29, 2014, 8:53:54 PM12/29/14
to koala-fra...@googlegroups.com
Could you try debugging that in kwf/trl.php?

line 25: function trl($string, $text = array()) {   
$string - right value

line 26: return Kwf_Trl::getInstance()->trl($string, $text);
I don't know how to debug that... 

Kwf_Trl::getInstance()->trl($string, $text) returns wrong value.

Artyom M

unread,
Jan 7, 2015, 9:31:10 AM1/7/15
to koala-fra...@googlegroups.com
Niko. can you help me with this?

Niko Sams

unread,
Jan 7, 2015, 12:51:09 PM1/7/15
to Koala Framework Dev
dig a bit deeper:
-> line 385 
-> calls _trlc (line 399)
-> check the return value of _findElement
-> _findElement (line 491)
-> add some debugging in here

I think the code is not too complicated...

Niko

Artyom M

unread,
Jan 11, 2015, 8:49:07 PM1/11/15
to koala-fra...@googlegroups.com
Niko,

I find a problem with RU cache and I think that's it.
See cache.jpg in attach.

There are files with RU translations in the mark area. As you can see, they not created succesfully. All symbols changed by "__" (one symbol - two underscores). That's why every equal length string values shows one value.
Fix please. But interesting how this would work with chinese/japanese translations =)

In debugging Trl.kwf I found problem in line 497:
$ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success);

$ret returns wrong value.

cache.JPG

Niko Sams

unread,
Jan 12, 2015, 8:44:45 AM1/12/15