-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Translate page strings
You want to set up a page for translation.
Within Jade, add the attribute data-i18n
to the element to set its text. The value of the attribute should point to a string in /app/locale/en.coffee
. To set the translated string to an attribute instead of the element's text value, preface the string with the attribute name in brackets. Within CoffeeScript, use $.i18n.t()
. Mark sections of templates that are not to be translated with DNT. Do not leave English strings in the template.
All static strings to be translated are kept in /app/locale/en.coffee. When a jade template is rendered by a CocoView, it finds all elements with the attribute data-i18n
, and based on the user's language settings, takes strings from the locale folder for that key. Strings that are not translated default to the English translation. We use a forked version of i18next.
module.exports =
common:
info: "Information"
enter_name: "Enter name here"
send: "Send"
sending: "Sending"
h1(data-i18n="common.info") // Will display "Information" in English.
input(data-i18n="[placeholder]common.enter_name") // Placeholder will be "Enter name here" in English.
button(data-i18n="common.send") // Button starts as "Send", but onSubmit, is changed to "Sending"
p Just have this in English // DNT
onSubmit: ->
@$('button').text($.i18n.t('common.sending'))
CodeCombat | Home | Blog | Forum | Teachers | Legal | Contribute
- Home
- Archmage Home
- Artisan Home
- Diplomat Home
- Archmage General
- Mission statement
- Coco Models
- Coding Guidelines
- Cookbook
- File system
- JSON Schema
- Technical overview
- Testing
- Third party software and services
- Artisan General
- Building A Level
- Coding Guidelines for Artisans
- Editing Thang Components
- Important Artisan Concepts
- Keyboard Shortcuts
- Debugging
- Artisan How-To Index
- Diplomat General
- i18n
- i18n Glossary nb
- i18n Glossary ru
- i18n Glossary es-419
- Dev Setup
- Dev Setup: Linux
- Dev Setup: Windows
- Dev Setup: Mac
- Dev Setup: Vagrant
- Dev Setup: Issues
- Game Engine
- Component
- Multiplayer
- Surface
- System
- Thang
- Thang Component System
- Tome
- World
- Artisan Tabs
- Components And Systems
- Scripts
- Settings
- Thangs
- Other
- Aether
- Client models
- Developer organization
- Educational Standards
- Events, subscriptions, shortcuts
- Chat Room
- Chat Room Rules
- Permissions
- Project Ideas List
- Treema
- Versioning
- Views