-
-
Notifications
You must be signed in to change notification settings - Fork 5
Language
Warning!
Because sf.language does allow you to re-bind the model template, you must make sure that the language isn't being created dynamically by user or untrusted sources.
There are 2 ways on how to add your language pack:
- Client side: Import language from the script
- Server side: Using server for serving the unknown language
But, the setup is pretty simple.
// sf.language.add(languageName, languageData);
sf.language.add('en-US', {
timestamp:"Current timestamp is {timestamp}",
my:{
name:"Your name is {name}"
}
});
If the language was missing and you was not setup the server side URL, the library will only warn on the console. Sometime the language pack will getting bigger if you have many languages for your app, so you may need to serving the language with your own implementation.
Currently no example, can you contribute? xD
Before starting, you will need to set the URL on where you serve the language.
sf.language.serverURL = 'http://localhost/language';
The library will request any missing language by using POST method to above URL. The example POST data that will be received by your server is just like below:
language = en-US
paths = '{"second":1,"my":{"test":1}}'
parameter | description |
---|---|
lang | Default language (sf.language.default ) that being used by the browser, and you can use it to select the language pack on your server |
paths | Is the missing language path (ex: second and my.test ). The server side response is up to you. The response from the server must be a JSON format because it will being merged with the current language pack on client side. After the language was loaded, the library will not requesting again until you clear the language sf.language.list['en']
|
- Framework
-
Installation
- Build Configuration
- Hot Reload
- Loader
- Model
-
Component
- Reserved Element
- Empty Shell
- Include external template
- Space
-
Views (Router)
- URI
- Static Template
- Language
- Element's query helper
- Events
- URL Request
- Window Extends