{"id":22316940,"url":"https://github.com/wszgrcy/cyia-localize","last_synced_at":"2025-10-04T02:47:37.766Z","repository":{"id":229117974,"uuid":"775809970","full_name":"wszgrcy/cyia-localize","owner":"wszgrcy","description":"angular localize standalone","archived":false,"fork":false,"pushed_at":"2024-03-24T02:42:02.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T08:03:07.801Z","etag":null,"topics":["angular","i18n","l10n","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wszgrcy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-22T04:48:43.000Z","updated_at":"2025-01-23T00:56:47.000Z","dependencies_parsed_at":"2024-03-22T06:40:01.632Z","dependency_job_id":null,"html_url":"https://github.com/wszgrcy/cyia-localize","commit_stats":null,"previous_names":["wszgrcy/cyia-localize"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wszgrcy%2Fcyia-localize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wszgrcy%2Fcyia-localize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wszgrcy%2Fcyia-localize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wszgrcy%2Fcyia-localize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wszgrcy","download_url":"https://codeload.github.com/wszgrcy/cyia-localize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245581826,"owners_count":20639048,"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","l10n","nodejs","typescript"],"created_at":"2024-12-03T23:08:19.238Z","updated_at":"2025-10-04T02:47:32.722Z","avatar_url":"https://github.com/wszgrcy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"| [中文](https://github.com/wszgrcy/cyia-localize/blob/master/readme.zh-Hans.md) | [English](./readme.md) |\n| --------------------------- | ---------------------- |\n\n---\n\n# Introduction\n\n- `@angular/localize` standalone version, allowed for use in any node/front-end project\n- Extract/merge/convert translation files through commands `i18n` / `l10n`\n\n\n# Source\n\n- Angular 17.3.1\n\n## Usage\n\n```ts\nimport { $localize } from '@cyia/localize';\n$localize`one`;\n```\n- Use `i18n ./src` Extract all `$localize` label template contents under `src` and generate `extract.json` metadata\n  \u003e Generate ID consistent with `@angular/localize`\n- Copy `extract.json` custom language translation and write the translation content into the `target` field\n- Use `i18n convert ./i18n-merge ./i18n` Convert translation metadata to `key-value` format for reference\n- Custom reference format import translation, such as\n\n```ts\n// Node environment demonstration\nimport path from 'path';\nimport fs from 'fs';\nimport { loadTranslations } from '@cyia/localize';\nexport const LanguageMap: Record\u003cstring, string\u003e = {\n  zh_cn: 'zh-Hans',\n  cn: 'zh-Hans',\n  en: 'en-US',\n  en_us: 'en-US',\n};\nexport function loadI18n() {\n  let lang = process.env['CR_LANG']?.toLowerCase();\n  if (!lang) {\n    if (process.env['LANGUAGE']) {\n      lang = process.env['LANGUAGE'].split(':')[0].toLowerCase();\n    } else if (process.env['LANG']) {\n      lang = process.env['LANG'].split('.')[0].toLowerCase();\n    }\n  }\n  let cache;\n  const filePath = path.join(__dirname, `./i18n/${LanguageMap[lang!] || lang || 'zh-Hans'}.json`);\n  if (ENV === 'test') {\n    cache = {};\n  } else {\n    if (!fs.existsSync(filePath)) {\n      cache = __non_webpack_require__('./i18n/zh-Hans.json');\n    } else {\n      cache = __non_webpack_require__(filePath);\n    }\n  }\n\n  loadTranslations(cache);\n}\n\nloadI18n();\n```\n\n## Merge other translations\n- If other dependency packages also use `@cyia/localize` and the published package contains translated/metadata text, use `i18n merge ./output ./pkg1 ./pkg2` merge multiple and then import them again\n\n## Update existing translations\n- `i18n ./src ./i18n-meta --update --name zh-Hans`Extract the content and use `zh-Hans` as the original file (no translation required), while files in other languages will add/remove corresponding text","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwszgrcy%2Fcyia-localize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwszgrcy%2Fcyia-localize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwszgrcy%2Fcyia-localize/lists"}