Sigma Php Ajax framework, Ajax Components, GUI Builder
May 23, 2012, 10:06:15 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to create Localisation  (Read 2091 times)
gikotim
Sr. Member
****
Posts: 49


View Profile
« on: December 08, 2009, 08:36:20 AM »

Hi!
I have seen the Sample: /Samples/linb/misc/lang/App/js/index.js where the function "linb.setLang" is used to switch locale - which is pretty cool!
BUT, I don't see of how to the needed resource files are created. In the API manual is written:
"Sets the language for the whole page. System will find and load the jsLinb locale file (in [linb.ini.path]/Locale/), and the application location file (in [linb.ini.appPath]/Locale/)."

hmm, so how to create these files?
Can you give me a hint, example, cookbook?

Many thanks in advance!

Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #1 on: December 08, 2009, 04:34:57 PM »

Just create a js file in the folder, and input json text.
Logged
gikotim
Sr. Member
****
Posts: 49


View Profile
« Reply #2 on: December 09, 2009, 04:55:24 AM »

ok, I had a look at the files in the Samples-folder, but I don't get the idea. Could you explain me the structure/syntax of these files?
I tried to create one on my own, but it don't work:
(linb.Locale.de||(linb.Locale.de={})).app={
    caption:{
          logo1:"Logo-Text",
        label1:"DemoDemo"
    }
};


There are different files with different headers:
     _.set(linb.Locale,["en","app"], {
or
     (linb.Locale.de||(linb.Locale.de={})).app={

I don't find any documentation on this topic.

The code for the GUI is:

Class('App', 'linb.Com',{
    Instance:{
        iniComponents:function(){
            // [[code created by jsLinb UI Builder
            var host=this, children=[], append=function(child){children.push(child.get(0))};
           
            append((new linb.UI.Label)
                .host(host,"label1")
                .setLeft(10)
                .setTop(20)
                .setWidth(450)
                .setHeight(24)
                .setCaption("bla bla")
                .setHAlign("left")
                .setFontSize("22px")
                .setFontWeight("bold")
            );
           
            append((new linb.UI.Label)
                .host(host,"logo1")
                .setLeft(840)
                .setTop(70)
                .setWidth(180)
                .setHeight(12)
                .setCaption("logo bla bla")
            );


I'd appreciate very much if you could give me a bit more explanation on that.

Thank you very much!
« Last Edit: December 09, 2009, 04:58:45 AM by gikotim » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #3 on: December 09, 2009, 04:37:17 PM »

1. add a "de.js" file to ”jsLinb/Locale/“(It's jsLinb's locale file. You can translate from en.js in the folder).
   copy "de.js" to "runtime/jsLinb/Locale/".

2. add "Locale/de.js" file(It's your application's locale file).



3.In your application:



And, if you finished "jsLinb/Locale/de.js", post it here please.
Logged
gikotim
Sr. Member
****
Posts: 49


View Profile
« Reply #4 on: December 10, 2009, 02:58:41 AM »

Thank you very much. Your code did the trick.
I'll translate the file in some spare time.


One strange thing still happens:
I can create language-files for any language (de.js / sp.js / fr.js / ....) and these files will be loaded from disk. I see this in firebug.
Only the english file: en.js is not loaded! I even can delete the file in /myApp/runtime/jsLinb/Locale/ and there is no error.
Why is this file handled different? Where is it located?


Thank you very much again!
« Last Edit: December 10, 2009, 04:14:29 AM by gikotim » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #5 on: December 10, 2009, 09:04:32 PM »

"en.js" was packed to linb-all.js/linb-debug.js. see the build file: build/build_linb.bat
Logged
artusolk
Jr. Member
**
Posts: 5


View Profile
« Reply #6 on: March 29, 2010, 12:42:12 PM »

And, if you finished "jsLinb/Locale/de.js", post it here please.
Hi dear linb
Want to build a de.js locale-file and will post it here.
But i've got a question about the built-in supported en date-formats:
1)
Are there supported ways to use extended en-dateformats with sigma visual ?
2)
isn't it a better way to extend the en used default date-formats first and make them visible at the UI-Components`?
perhaps missing
YYMMDD to get 10/09/31 or 09/01/02 (january the 2nd 2009) so we could overwrite it in de.js to set 31.09.10 instead
or
YYYYMMDD by default to get 2010/09/31 or 2009/01/02 (january the 2nd 2009)
to set 31.09.2010 instead
The leading zero formats with YY or YYYY are often used display-masks at germany

What do you think about ?
At this time i just can overwrite the existing en-mask YMD with something like that but only this one

or is there a better way to?
Greetings from Hamburg,
artusolk
« Last Edit: March 29, 2010, 12:44:48 PM by artusolk » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #7 on: March 29, 2010, 05:37:15 PM »

in DatePicker,

the show mode text is from : date.getText(new Date(parseInt(value)), 'ymd')

the editing mode text is from : date.get(v,'y')+'-'+(date.get(v,'m')+1)+'-'+date.get(v,'d')


If you want change show text only,  your code is OK.

But if you want to change editing mode text, you have to use CF


refer to ComboInpu.js line 395 - 421.

« Last Edit: March 29, 2010, 05:41:11 PM by linb » Logged
aaz
Newbie
*
Posts: 1


View Profile
« Reply #8 on: May 12, 2011, 07:17:45 AM »

Hi,
Please help :-)
I need to create the button for changing language for the end user.
I found an example, but  it didn't work for me:
http://sigmawidgets.com/forum/visual-ajax-gui-builder/how-to-create-localisation/
Where I have made a mistake?

1. I created new project and copied the JavaScript Code  from the example into my test-application. It works. There is one label “slabel1”and one button “to de”
htdocs/apps/sigma-visual-builder/VisualJS/projects/LocationTest/App/js/index.js

Class('App', 'linb.Com',{
    Instance:{
        iniComponents:function(){
            // [[code created by jsLinb UI Builder
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append((new linb.UI.SLabel)
                .host(host,"slabel1")
                .setLeft(210)
                .setTop(70)
                .setCaption("$app.caption.slabel1")
            );
            
            append((new linb.UI.SButton)
                .host(host,"slabel2")
                .setLeft(250)
                .setTop(120)
                .setCaption("to \"de\"")
                .onClick("_sbutton3_onclick")
            );
            
            return children;
            // ]]code created by jsLinb UI Builder
        }, 
        _sbutton3_onclick:function (profile, e, src, value) {
          
           // change locale to 'de'
            linb.setLang('de');
        }
    }
});

2. I created new local file with code from the example
htdocs/apps/sigma-visual-builder/VisualJS/projects/LocationTest/Locale/de.js

(linb.Locale.de||(linb.Locale.de={})).app={
    caption:{
        slabel1:"DemoDemo"
    }
};

3.I copied the same de.js file into folder
htdocs/apps/sigma-visual-builder/runtime/jsLinb/Locale

4.I run this application and press the button “to de” .
As I understand the text on the label “slabel1” should change to "DemoDemo" but doesn't . Why?

Thank you for help!
Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #9 on: May 12, 2011, 05:43:56 PM »

>> 3.I copied the same de.js file into folder
>> htdocs/apps/sigma-visual-builder/runtime/jsLinb/Locale

In step 3, the "de.js" file is not the same one in step 2.

Here, you have to translate "/runtime/jsLinb/Locale/en.js" to  "/runtime/jsLinb/Locale/de.js".
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!