0.1.0
- Go to the root of the project adapteach
You need to install all the node dependencies :
$ npm install
Run the default gulp task to watch jsx and sass files :
$ gulp
Run Activator :
$ activator
[adapteach] $ run
Run Activator :
$ ./activator
[adapteach] $ run
To create a new feature, you need to create a dedicated branch first.
- Go to exp branch
$ git checkout exp
- create a new local branch:
$ git checkout -b <branch-name>
- add modified files to your next commit (in this case you'll add all the edited files)
$ git add -A
- Commit
$ git commit -m "<your commit message>"
- Push to the remote repository on a new branch remote (usually you pick the same name as your local branch)
$ git push -u "<your remote branch name>"
Now, you can merge the "exp" branch before submitting a pull request
- fetch data from origin to update your remote tracking
$ git fetch origin exp
- merge branch "origin/exp" into your local branch
$ git merge origin/exp
Finally, just go on github and make your pull request from your remote branch to the exp branch.
In the folder public
, you can find a folder i18n
with multiple files as messages_<locale>.json
.
A variable i18n
is injected in the window to access the i18n engine instance.
there are different cases:
SIMPLE TRANSLATION
key exemple in the json translation file
{
translation_key: "value"
}
source code to use it
i18n.t("translation_key")
=> "value"
INTERPOLATION
key exemple in the json translation file
{
translation_key: "translation %{variable}"
}
source code to use it
i18n.t("translation_key", {variable: "value"})
=> "translation value"
PLURALIZATION
key exemple in the json translation file
{
translation_key: "%{smart_count} value |||| %{smart_count} values",
}
source code to use it
i18n.t("translation_key", {smart_count: 0});
=> "values"
i18n.t("translation_key", {smart_count: 1});
=> "value"
i18n.t("translation_key", {smart_count: 2});
=> "values"
SPECIFIC SERVER CASE
If you wanna create a message on the server side and use the i18n engine from the client, you have to follow these instructions: Create your translation in themessages_<locale>.json
On the server side, your message must have the following structure
{
key: "translation_key",
params: {
any_key_you_want: "param value"
}
}
KEY
and PARAMS
are keywords here. You must use it. the other keys are completely your call.
you will have this kind of source code to do this (exemple of a json response in scala Action)
Ok(Json.obj("any_key" -> Json.obj("key" -> "translation_key", "params" -> Json.obj("param_key" -> "param value")).stringify))
In this case, param_key
is a variable corresponding to the var you set in the translation message like smart_count
(ref to the pluralization exemple)
If you wanna render a global error in a form, use the param_key global
instead of any_key
; which is a random choice just for the exemple in this case; and the error will automatically render just under the submit button.