{"id":18036321,"url":"https://github.com/haasstefan/ngx-locutus","last_synced_at":"2025-03-27T08:30:40.574Z","repository":{"id":39863394,"uuid":"494721926","full_name":"HaasStefan/ngx-locutus","owner":"HaasStefan","description":"The alternative internationalization (i18n) library for Angular","archived":false,"fork":false,"pushed_at":"2022-05-24T08:16:27.000Z","size":296,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T10:51:08.246Z","etag":null,"topics":["angular","i18n","translation"],"latest_commit_sha":null,"homepage":"","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/HaasStefan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-21T08:15:22.000Z","updated_at":"2022-05-31T12:23:21.000Z","dependencies_parsed_at":"2022-08-25T17:53:42.755Z","dependency_job_id":null,"html_url":"https://github.com/HaasStefan/ngx-locutus","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaasStefan%2Fngx-locutus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaasStefan%2Fngx-locutus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaasStefan%2Fngx-locutus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaasStefan%2Fngx-locutus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HaasStefan","download_url":"https://codeload.github.com/HaasStefan/ngx-locutus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245809603,"owners_count":20676017,"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","i18n","translation"],"created_at":"2024-10-30T12:12:33.549Z","updated_at":"2025-03-27T08:30:39.985Z","avatar_url":"https://github.com/HaasStefan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NGX Locutus\n- The alternative **Angular Translation Library** used for large scale microfrontend translations. \n- No more worrying about shared translation assets.\n- Truly independent translations. \n- Lazy loaded translations.\n- Scopes by default.\n\n## Demo\n\nA project named demo is inside the projects folder which should explain the most basic concepts.\n\n## Installation\n\n    npm install ngx-locutus --save\n\n## Usage\n\n\n### Translation files\nLocutus uses Typescript constants as translation files. It is suggested to create an interface definition for each translation and let the explicit translation constant be of the interface type. \n\nSuggested file structure:\n\n|--assets\n\n|----i18n\n\n|------scope1\n\n|--------en.ts\n\n|--------de.ts\n\n|--------scope1.ts\n\nscope1.ts includes the interface definition for the translation object and also defines an array of TranslationLoaders. It is of big importance that the loaders do reference the translation files in a hardcoded manner such that the files will not be tree-shaken. \n\n    export const Scope1Loaders: TranslationLoader[] = [\n      { de: () =\u003e from(import('./de').then(t =\u003e t.DE)) },\n      { en: () =\u003e from(import('./en').then(t =\u003e t.EN)) }\n    ];\n\n\n### Import LocutusModule\n\nCall forRoot() in your AppModule and forChild in each feature module. \n- **forRoot** needs an array of TranslationConfiguration consisting of the scope-name, translation-loaders and the active language\n- **forChild** needs an array of TranslationConfiguration consisting of the scope-name, translation-loaders \n\nAppModule Import:\n\n     LocutusModule.forRoot([{\n      loaders: Scope1Loaders,\n      scope: 'scope1',\n      language: 'de'\n    }])\nFeature Module Import:\n\n    LocutusModule.forChild([{\n      scope: 'picard',\n      loaders: PicardLoaders\n    }])\n\n\n### Translation API\nUse the locutus **directive** to make translations in your template:\n\n    \u003cng-container *locutus=\"let t of 'scope1'\"\u003e\n      {{t.title}}\n    \u003c/ng-container\u003e\n\nOr use the **pipe**:\n\n    {{ 'title' | locutus:'scope1' | async }}\n\nTo interpolate a translation:\n\n    {{ 'title' | locutus:'scope1':'test' | async }}\n\nor: \n\n    {{ 'title' | locutus:'scope1' | interpolate:'test' | async }}\n\nOr in the **code** using the LocutusService:\n\nTo retrieve a specific key in a scope:\n\n    this.title$ = this.locutus.translate('scope1', 'title');\nTo retrieve an entire scope:\n\n    this.scope1$ = this.locutus.getTranslations('scope1');\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaasstefan%2Fngx-locutus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaasstefan%2Fngx-locutus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaasstefan%2Fngx-locutus/lists"}