{"id":21420560,"url":"https://github.com/maxhoffmann/translations","last_synced_at":"2025-07-14T06:32:21.525Z","repository":{"id":25828581,"uuid":"29267906","full_name":"maxhoffmann/translations","owner":"maxhoffmann","description":":earth_africa: translations api for node.js, browsers and the command line","archived":false,"fork":false,"pushed_at":"2016-02-19T16:00:08.000Z","size":25,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-14T06:43:55.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxhoffmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-14T21:57:39.000Z","updated_at":"2019-04-03T08:53:21.000Z","dependencies_parsed_at":"2022-07-27T05:32:22.293Z","dependency_job_id":null,"html_url":"https://github.com/maxhoffmann/translations","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhoffmann%2Ftranslations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhoffmann%2Ftranslations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhoffmann%2Ftranslations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhoffmann%2Ftranslations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxhoffmann","download_url":"https://codeload.github.com/maxhoffmann/translations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225957986,"owners_count":17551331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T20:18:16.327Z","updated_at":"2024-11-22T20:18:16.826Z","avatar_url":"https://github.com/maxhoffmann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# translations [![version][1]][2] [![build][3]][4]\ntranslations api for node.js, browsers and the command line.\n\n## Installation\n\n```js\nnpm install translations\n```\n\n## Usage\n\n```js\nvar locale = require('locales/de-DE.json'); // node.js;\nvar locale = window.locale; // browser example\n\nvar t = translations(locale); // production mode: ignores most errors\nvar t = translations(locale, true); // development mode: throws more errors\n\nt('How are you?');\n// \"Wie geht es dir?\"\n\nt('Hello {name}, how are you?', { name: 'Max' });\n// \"Hallo Max, wie geht es dir?\"\n\nt('Hello {name}, how is {thing}?', { name: 'Max', thing: t('the weather') });\n// \"Hallo Max, wie ist das Wetter?\"\n\nt('undefined key in locale');\n// throws error in development mode for undefined keys\n// returns empty string in production mode\n\nt('Hello {name}, how is {thing}?', { name: 'Max' });\n// throws error in development mode for undefined variables\n// prints placeholders in production mode\n```\n\n__de-DE.json__\n\n```json\n{\n  \"How are you?\": \"Wie geht es dir?\",\n  \"Hello {name}, how are you?\": \"Hallo {name}, wie geht es dir?\",\n  \"Hello {name}, how is {thing}?\": \"Hallo {name}, wie ist {thing}?\",\n  \"the weather\": \"das Wetter\"\n}\n```\n\n## Command Line\n\n### Installation\n\n```bash\nnpm install translations -g # if you want to use the cli globally\n```\n\n### sync\n\n```bash\n# sync locales\ntranslations sync \u003cmaster\u003e \u003ctarget\u003e\n\n# example\ntranslations sync locales/en.json locales/de-DE.json\n```\n\n`translations sync` syncs the `master` translations file with the `target` one:\n\nIf `target` has values that are not strings, it throws an error.\n\nIf `target` does not exist yet, a copy of `master` will be created with the target’s name (`de-DE.json`).\n\nIf `target` does already exist, the command does the following:\n- every key not found in `master` is removed\n- every key not found in `target` is added\n\n### export\n\n```bash\n# export locales for browser usage\ntranslations export \u003cinputDirectory\u003e \u003coutputDirectory\u003e --assign \u003cvariable\u003e\n```\n\n`translations export` will create or overwrite the given output directory with js files for valid locales in the input directory. Each js\nfile assigns the locale’s translations to the given variable (or `window.locale` by default).\n\n## LICENSE\n\nMIT (2015) Maximilian Hoffmann\n\n[1]: http://img.shields.io/npm/v/translations.svg?style=flat\n[2]: https://www.npmjs.org/package/translations\n[3]: http://img.shields.io/travis/maxhoffmann/translations.svg?style=flat\n[4]: https://travis-ci.org/maxhoffmann/translations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhoffmann%2Ftranslations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxhoffmann%2Ftranslations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhoffmann%2Ftranslations/lists"}