Socket
Socket
Sign inDemoInstall

meteor-accounts-t9n

Package Overview
Dependencies
100
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    meteor-accounts-t9n

Translations for Meteor projects, almost i18n


Version published
Weekly downloads
2K
increased by35.15%
Maintainers
1
Install size
498 kB
Created
Weekly downloads
 

Readme

Source

Translations for the meteor standard packages (almost i18n)

This package offers translations for accounts-base, accounts-passwords, accounts-entry, accounts-templates-core and billing. Contributions for other packages are welcome. We try to translate only messages that might pop up at a users screen as developers are expected to understand English errors anyway.

Translations are currently available for Arabic, Catalan, Chinese (Mandarin), Chinese (Traditional), Chinese (Hong Kong), Croatian, Czech, Danish, Dutch, Estoninan, Farsi, Finish, French, French (Canada), German, Greek, Hebrew, Hungarian, Indonesian, Italian, Japanese, Khmer, Korean, Norwegian, Polish, Portuguese (Brasil), Portugues (Portugal), Romanian, Russian, Slovak, Slovenian, Spanish (South America), Spanish (Spain), Swedish, Thai, Turkish, Ukrainian and Vietnamese.

Version 2.0.0

The second generation of meteor-accounts-t9n is able to run with npm alone. This means it can even be used with plain Node.js applications, not only within Meteor, see in ./examples/npm how this could work.

When using npm the translation files will no longer be eagerly loaded. Several people asked for this feature to safe bandwidth and it is possible now, this closes #161.

To make it work with npm the files have been translated to JavaScript, so if you use CoffeeScript you can require from the main directory and if you use JavaScript you would import/require from build.

These examples show different use cases:

  • meteorPackage: This is way it has been used in former versions as a meteor package.
  • meteorNpm: Use t9n as npm package within Meteor.

Installation

meteor add softwarerero:accounts-t9n

Off course one can easily add translations for applications. By putting a file like myapp.es in a folder under lib translations can be used on the client and on the server. Example:

es =
  meteor: "meteoro"
T9n.map "es", es

API

Set a current language for translations:

T9n.setLanguage("es")

Get a translation in Javascript:

T9n.get(code)

Examples:

  • T9n.get('name');
  • T9n.get('store.purchase');
  • T9n.get('error.accounts.User not found');

Get a localized text in a template

{{t9n code}} {{t9n code parameter1='value'}}

Example: {{t9n "store.purchase"}}.

If a translation is not found the key is displayed. To spot not translated keys a prefix and a postfix can surround the key, they default to ">" and "<" so a you would see ">nonExistantKey<". You can change the pre- and postfix:

T9n.missingPrefix = ">" T9n.missingPostfix = "<"

If you use get you can also suppress printing of the prefix and postfix if you set the second parameter to false (it defaults to true). T9n.get code, false

Get a localized text with parameters

Optionally named parameters can be used, naming them allows for repetition.

T9n.get code, true, args

Example:

If you define a string in your language file like

'pun': '@{subject} @{predicate} @{adverb} @{object}. Frische @{object} @{predicate} @{subject}.'

and have an object like

args =
  subject: "Fischer's Fritz"
  predicate: 'fischt'
  object: 'Fische'
  adverb: 'frische'

you could call

T9n.get 'pun', true, args

and that should give you

'Fischer's Fritz fischt frische Fische. Frische Fische fischt Fischer's Fritz.'

You must specify the second argument for prefix/postfix too, I am sorry.

Define translations

T9n.map language, yourMap

Example:

T9n.map 'en',
  hello: 'world'
  store:
    purchase: 'buy now'
    basket: 'basket'

Tip: If you do not want to expose the reason why a login was unsuccessful for security reasons. They could overwrite the corresponding messages:

T9n.map 'en',
  error:
    accounts:
      'User not found': 'Not for you'
      'Incorrect password': 'Not for you'

Language variants (v1.2)

T9n.language = 'en'
equals T9n.get('error.accounts.Incorrect password'), 'Incorrect password'

T9n.map 'en_GB', 'error.accounts.Incorrect password': 'You might want to enter a more correct version of your password'
T9n.language = 'en_GB'
equals T9n.get('error.accounts.Incorrect password'), 'You might want to enter a more correct version of your password'

Starting from (v.1.2.2) you can also do setLanguage('en-GB') and it gets converted internally to 'en_GB'. This is usefull for taking the language string directly from an http header.

#Language codes and contributions

CodeLanguageContributor(s)
arArabiceahefnawy
caCatalanixdi
csCzechmdede
daDanishLarsBuur
deGermansoftwarerero, robhunt3r, sclausen, sarasate
elGreekmutil
esSpanishsoftwarerero, robhunt3r, PolGuixe, mortaldraw
es_formalFormal spanishsoftwarerero, robhunt3r, PolGuixe, mortaldraw
es_ES / es-ESSpanish for Spainmaomorales, PolGuixe, mortaldraw
es_ES_formal / es-ESFormal spanish for Spainmaomorales, PolGuixe, mortaldraw
etEstoniankrishaamer
faFarsipajooh
fiFinnishxet7
frFrenchdjhi
fr_CAFrench (Canada)huguesbrunelle
heHebrewnoamyoungerm
hrCroatiantnedich
huHungarianbalazskiss
idIndonesianhellstad
itItaliansplendido
jaJapanesey-ich, exKAZUu
khKhmeryuomtheara
koKoreancandicom, buo
nlDutchwillemx, louwers
no_NB / no-NBNorwegian bokmålkjetilge
plPolishpwldp, wareczek, spiotr12
ptPortuguese (Brasil)alanmeira, Tadeu Caldararo
pt_PT / pt-PTPortuguese (Portugal)tdbs
roRomanianalexhuszar
ruRussiantimtch
skSlovakMartinBucko, aladinko
slSlovenianalesvaupotic
svSwedishtimbrandin
thThaiPrawee
trTurkishserkandurusoy
ukUkrainianSkeLLLa
viVietnameseolragon
zh_cn / zh-CNSimplified Chineselaosb
zh_hk / zh-HKHong Kong Chinesedaveeel
zh_tw / zh-TWTaiwan Chinesevictorleungtw

Note: "xx" or "xx-XX" is the IETF language tag standard format.

Send only some language files to the client (new in version 1.1.0)

If you have a need to reduce bandwidth you can specify which languages to send to the client by setting an environment variable like T9N_LANGUAGES='es,de'. Now only Spanish and German should go over the wire instead of all translations. With the current package manager this does not work anymore. If you need that functionality delete ~/.meteor/packages/softwarerero_accounts-t9n and instead copy it directly into your project (you can go to myproject/packages and issue git clone https://github.com/softwarerero/meteor-accounts-t9n.git). Now it should work again.

History

This package is inspired by subhog's just-i18n and included this as a dependency before version 0.0.3. Sadly the all project versions before 0.0.17 where deleted from Atmosphere when they updated to the new Meteor package format.

License

MIT

FAQs

Last updated on 02 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc