How to create a basic translation (I18n) function
Here is one approach you might take to creating a translate function.
This function accepts three parameters:
- translations - an object which might look something like this:
|
|
key - a string representing a potential entry in the translations object. Nesting is represented with a
.
. For example, if a user wanted to get the create account text for our english buttons then they would use a key likeenglish.buttons.create_account
.substitutions - an optional flat object which tells translate how to handle interpolation. A replacement occurs when there is a match with the key and the interpolated argument is found in substitutions
|
|