Created
March 18, 2013 17:49
-
-
Save jtomasek/5189239 to your computer and use it in GitHub Desktop.
Javascript translations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Javascript translations: | |
base requirement: | |
- have no hardcoded strings in javascript | |
general aproach: | |
- have strings defined in view file (html/erb/haml...) in data attribute, this enables their translation | |
- access these translated strings from javascript | |
angular directive approach: | |
- we need to translate strings used in directive templates | |
- to enable translation, template has to be erb/haml and it has to be served by rails to actually perform the translation | |
solution: create directive_templates_controller that will serve the directive templates, and define the routes for it. | |
then in directive definition, load the template eg. templateUrl: "directive_templates/tooltip". This will feed the directive | |
with correct translated template. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment