CYJS is basically multilingual.

Any string inside an identified HTML tag will be automatically translated. These tags are label, option ,th ..

Any string inside a title HTML attribute will be automatically translated.

New dedicated l tag in HTML files which contains a string to be translated.

In all cases, if you forget to translate some strings, the contain itself will be displayed, so it’ll be very easy for you to translate forgotten strings 😉

Languages are defined in JS resource files in js/lang directory, as en.js or fr.js, very easy to translate, containing such lines :

// index
cyString['PROJECT'] = "MY CYJS APP"; 
cyString['FOOTER'] = "MY CYJS FOOTER APP"; 
cyString['IDheadericonmenu'] = 'Click to mask/open or Dbl-click to reset';
cyString['IDheadericonuser'] = 'User menu';
// sidemenu
cyString['CYJS UI'] = "CYJS UI"; 
cyString['CYJS Tables'] = "CYJS Tables";  
// usermenu
cyString['Profil'] = "Profile"; 
cyString['Deconnecter'] = "Logoff"; 
cyString['Profile updated'] = "Profile updated";
cyString['Profile not updated'] = "Profile non updated";
cyString['PASSWORD AGAIN'] = "Repeat password";
cyString['PASSWORD NOT MATCH'] = "Different passwords";
// login
cyString['LANGAGE'] = "Language";
cyString['Francais'] = "French";
cyString['Anglais'] = "English";
cyString['USERNAME'] = "Username";
cyString['PASSWORD'] = "Password";
cyString['PLEASE LOGIN'] = "Please login";

Any string predefined by the framework can be overriden. Note that the project title is set there in ‘PROJECT ‘, for both header and footer. Try to set something short as title will also be set on browser tab.

Default lang is defined in js/config.js

How it works ?

Language selection is simply made with the GET var lang. You can directly select a language by calling your app like this :

http://myfirstapp.com/?lang=fr

Internally, the Javascript var cyLang will be set also.

When loading the php/mypage.html, all translation will be automatically made :

  • the label / option / th tags and title attributes
  • the new l tag is an dedicated CYJS tag to specifiy a text to translate, refers to example pages

The login page provided with the framework gives a good Javascript example on how to manage language when a user logs in.

Internal CYJS vars

Default CYJS framework languages are defined in CYJS/js/lang.default.js. If you want to add your own language, juste add a new test in that file by duplicating the en part then adapt it. A language name should have only 2 characters. Predefined languages are english (en) and french (fr).

If you add a language, you must also create language files for integrated plugins, these are defined in CYJS/js/lang. You’ll see there that others languages are already available, just copy the english sets in your new language files by respecting filnames conventions.

Please contribute

You would be very kind to send us your translation job so we would include them in a future release, that would be fair 😉