{"id":15412585,"url":"https://github.com/cristianbote/angular-translate-json","last_synced_at":"2025-03-28T03:16:04.990Z","repository":{"id":66106309,"uuid":"88150643","full_name":"cristianbote/angular-translate-json","owner":"cristianbote","description":"Angular(latest) translate json","archived":false,"fork":false,"pushed_at":"2017-04-14T08:48:50.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T04:24:48.714Z","etag":null,"topics":["angular","angular-translate","angular2","angular4","javascript","json","translation","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/cristianbote.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-13T09:53:23.000Z","updated_at":"2018-05-10T15:44:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"1de3d208-bbf5-4682-a0ba-743c18ed095c","html_url":"https://github.com/cristianbote/angular-translate-json","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbote%2Fangular-translate-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbote%2Fangular-translate-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbote%2Fangular-translate-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbote%2Fangular-translate-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristianbote","download_url":"https://codeload.github.com/cristianbote/angular-translate-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960817,"owners_count":20700781,"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":["angular","angular-translate","angular2","angular4","javascript","json","translation","typescript"],"created_at":"2024-10-01T16:53:49.175Z","updated_at":"2025-03-28T03:16:04.957Z","avatar_url":"https://github.com/cristianbote.png","language":"TypeScript","readme":"# Angular Translate Json\nTranslations module for latest version of angular. It's built to support latest angular version, with a friendly to use api.\n\n\u003e *Inspired by https://github.com/angular-translate/angular-translate*\n\n[![npm version](https://badge.fury.io/js/angular-translate-json.svg)](https://badge.fury.io/js/angular-translate-json) [![Build Status](https://travis-ci.org/cristianbote/angular-translate-json.svg?branch=master)](https://travis-ci.org/cristianbote/angular-translate-json)\n\n## How to get it\nIt's up on npm, so you can do:\n```bash\nnpm install --save angular-translate-json\n```\n\n## How it works\n\n##### 1. Define the module and configurations\n```typescript\n// Imports\nimport { AngularTranslateJsonModule, TranslateService } from 'angular-translate-json';\n\n\n// Import it\n@NgModule({\n    imports: [\n        AngularTranslateJsonModule.forRoot(\n            // You can either define the settings  here\n            {\n                locale: 'en',\n                path: 'my/path/to/translations'\n            }\n        ),\n    ]\n})\nclass MyAngularModule {\n    \n    constructor( private translateService: TranslateService ) {\n        \n        // Or here\n        translateService.setConfig({\n            locale: 'en',\n            path: 'my/path/to/translations'\n        });\n    }\n}\n```\n##### 2. Your translation file\nAnd this is your `en.json` file\n```json\n{\n  \"COMMON\": {\n    \"HELLO\": \"Hello mate!\",\n    \"HELLO_USER\": \"Hello {{userName}}!\"\n  },\n  \"PAGE_TITLE\": \"Page title\"\n}\n```\n\n##### 3. Usage in component\nNow, we're ready to use inside our components.\n```typescript\n@Component({\n    template: `\n        \u003cdiv class=\"page\"\u003e\n            \u003cdiv class=\"title\" translate=\"PAGE_TITLE\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"greet\" translate=\"COMMON.HELLO\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"greet\" translate=\"COMMON.HELLO_USER\" [translateValues]=\"userData\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n    `\n})\nclass MyComponent {\n    userData = {\n        userName: 'johnsnow'        \n    }\n}\n```\n\n##### 4. More options to use it\nYou could either use it as a atttribute(directive) or pipe, or simply by calling the service directly.\n##### Directive\n```html\n\u003cdiv class=\"greet\" translate=\"COMMON.HELLO\"\u003e\u003c/div\u003e\n```\n##### Pipe or filter\n```html\n\u003cdiv class=\"greet\"\u003e{{'COMMON.HELLO' | translate}}\u003c/div\u003e\n```\n##### Using the service\n```typescript\nimport { TranslateService } from 'angular-translate-json';\n\n@Component({\n    template: `{{myNameIs}} {{name}}`\n})\nclass NameBadgeComponent {\n    \n    myNameIs = '';\n    name = 'John Snow';\n    \n    constructor( private translateService: TranslateService ) {\n        translateService.getTranslation('COMMON.HELLO')\n            .subscribe(res =\u003e {\n                this.myNameIs = res;\n            });\n    }\n    \n}\n```\n\n## Feedback\nLet me know if there's something broken and I'll be more than happy to address it.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristianbote%2Fangular-translate-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristianbote%2Fangular-translate-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristianbote%2Fangular-translate-json/lists"}