{"_id":"fire-i18n","_rev":"5-dd49e3ce303b6f6b35b607fbf1052070","name":"fire-i18n","description":"Localization expressions for fire.js","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"fire-i18n","description":"Localization expressions for fire.js","version":"0.1.0","homepage":"http://firejs.firebase.co","author":{"name":"Firebase.co","email":"npm@firebase.co","url":"http://www.firebase.co"},"main":"./index.js","repository":{"type":"git","url":"git://github.com/firejs/fire-i18n.git"},"bugs":{"email":"firejs@firebase.co","url":"https://github.com/firejs/fire-i18n/issues"},"keywords":["firejs","fire.js","localization","i18n","internationalization","localization","locale","multi-language","languages","ignitable"],"contributors":[{"name":"Johan Hernandez","email":"johan@firebase.co"}],"dependencies":{"fire":">= 0.1.0"},"devDependencies":{"vows":">= 0.5.11"},"scripts":{"test":"make"},"engines":{"node":">= 0.4.5"},"licenses":[{"type":"MIT","url":"https://github.com/firejs/fire-i18n/blob/master/LICENSE"}],"_npmUser":{"name":"firebaseco","email":"npm@firebase.co"},"_id":"fire-i18n@0.1.0","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.5","_defaultsLoaded":true,"dist":{"shasum":"1d023f793de631e92cc04a2db47906a3c26e9c2c","tarball":"https://registry.npmjs.org/fire-i18n/-/fire-i18n-0.1.0.tgz","integrity":"sha512-mSF+frzpnAw4j7/u9tOY74Pe1DoFM4a4VLvw4J0S0oiz1KlMk/RB6g/nyinxewa/3ZSTiSNRtcN+iWAQUAg+nA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG7NahqxRB840MXNIbdqc43FaEenq4D/lgSxYhPaqYbgAiBUTZ/uevFtYXyfhTjv3aTAHO4Or0DJQZOYDpJ/Xslifg=="}]},"maintainers":[{"name":"firebaseco","email":"npm@firebase.co"}]}},"readme":"#fire-i18n\n[![Build Status](https://secure.travis-ci.org/firejs/fire-i18n.png)](http://travis-ci.org/firejs/fire-i18n)\n\nInternationalization module for [fire.js](https://github.com/firejs/fire)\n***\n\n## Installing\n\n### using NPM\n\n    npm install fire-i18n\n\n### using Github(unstable)\nIn the root of your project run:\n\n    git clone git://github.com/firejs/fire-i18n.git node_modules/fire-i18n\n\n## Working with i18n\n\nThe language is set by a variable called \"currentLocaleId\". If not set, the default locale is \"en\".\n\n## @i18n\n\nReturns the string for the current locale. The hint is the key in the global dictionary you want to retrieve. If the key can not be found, it will return a empty string. The input of the expression will be used as replacement of the tokens as the translation is retrieved.\n\n### Example with key\n\nAssuming that you have a dictionary like this:\n\n    {\n\t\t\"en\": {\n\t\t\t\"InvalidUser\": \"Invalid user\"\n\t\t},\n\t\t\"es\": {\n\t\t\t\"InvalidUser\": \"Usuario invalido\"\n\t\t}\n\t}\n\nWhen you use `@i18n` with the key `InvalidUser`:\n    \n\t{\n\t\t\"@i18n(InvalidUser)\":null\n\t}\n\nIt will return \"Invalid user\" for `en-us` and \"Usuario invalido\" for `en-es`.\n\n### Example with replacement tokens\n\nDictionaries can contain replacement tokens in the translations.\n\nExample, given the following dictionary:\n\n    \"en\": {\n\t\t\"ChannelNotAvailable\": \"Channel '{name}' is not available\"\n\t}\n\nWhen you use `i18n` with an input:\n\n\t{\n\t\t\"@i18n(ChannelNotAvailable)\": {\n\t\t\tname: \"News\"\n\t\t}\n\t}\n\nIt will return \"Channel 'News' is not available\"\n\n## Implementing i18n resources for a fire.js application\n\ni18n module will try to load all the .i18n.json files from the i18n in the root of the application.\n\nExample:\n\nIf you have a program in the following path `./MyApp.fjson` i18n will try load all the `i18n.<lang>.json` files from `./i18n/`.\n\n## Implementing i18n resources in a custom module\n\nImplementing i18n resources in a module works the same way than applications, except for a simple call you have to make in your main script:\n\n    require('fire-i18n').enableModule(module)\n\n**Note:** You must pass `module` and not `exports` or `module.exports`.\n\nWhen you call `enableModule` i18n will load all the resources for your module using the following rules:\n\n* A module defined as `./MyModule.js` will load resources from `./i18n/`\n* A module defined as `./node_modules/MyModule.js` will load resources from `./node_modules/i18n/`\n* A module defined as `./node_modules/MyModule/index.js` will load resources from `./node_modules/MyModule/i18n/`\n\n### Custom Expressions\n\nCustom expressions written in Javascript can also take advantage of i18n by calling `enableExpression`, example:\n\nExample:\n\n    var i18n = require('fire-i18n')\n\tvar fire = require('fire')\n    function SampleExpression1() {\n\t\n\t}\n\tSampleExpression1.prototype = new fire.Expression()\n\ti18n.enableExpression(SampleExpression1)\n\n\tSampleExpression1.prototype.execute = function() {\n\t\tthis.setResult(this.getI18nText('sampleModule1.ErrorMsgExpression',{number:422}))\n\t}\n\nYou just need to pass the expression class and you should be able to use  `getI18nText` using a key and replacements object.\n\nFor a full example check [test at test/testFromModule](https://github.com/firejs/fire-i18n/tree/master/test/testFromModule).\n\n## Considerations\n\nfire-i18n uses the standard key discovery strategy:\n\n* If the locale id specifies the region(e.g \"en-us\"), it will look for the language and region. If the key can not be found, it will look for the key using the language only(e.g \"en\").\n* If the locale id only specifies the language(e.g \"en\"), it will look for the language key only.\n* If the key can not be found using lang-region or lang only strategies, a discovery will be perfomed in the default language(en).\n* If the key can not be found in the default language, an empty string is returned.\n\nWhen you set the locale id using the variable `currentLocaleId` remember that the values must use lowercase dash notation, meaning that if you want to provide the locale for English in Region United States then you should use \"en-us\" and not \"en-US\", \"en\\_us\" or \"en\\_US\".\n\n\n## Cloning the Repository\n\n    git clone git://github.com/firejs/fire-i18n.git\n\n### Tests\n\n    make run-tests\n\n### Collaborating\n\n* Johan (author). Email: *johan@firebase.co*, Skype: *thepumpkin1979*\n\n## MIT License\n\nCopyright (c) 2011 Firebase.co - http://www.firebase.co\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","maintainers":[{"name":"firebaseco","email":"npm@firebase.co"}],"time":{"modified":"2022-06-18T01:01:11.222Z","created":"2011-11-25T20:51:08.182Z","0.1.0":"2011-11-25T20:51:10.403Z"},"author":{"name":"Firebase.co","email":"npm@firebase.co","url":"http://www.firebase.co"},"repository":{"type":"git","url":"git://github.com/firejs/fire-i18n.git"}}