{"id":22775533,"url":"https://github.com/chlbri/internationalization","last_synced_at":"2025-03-30T13:15:30.060Z","repository":{"id":43415455,"uuid":"463499339","full_name":"chlbri/internationalization","owner":"chlbri","description":"For internationalization ","archived":false,"fork":false,"pushed_at":"2022-03-02T12:42:42.000Z","size":1395,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-02-05T14:50:39.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chlbri.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}},"created_at":"2022-02-25T10:58:58.000Z","updated_at":"2022-02-25T22:37:38.000Z","dependencies_parsed_at":"2022-09-12T09:50:39.953Z","dependency_job_id":null,"html_url":"https://github.com/chlbri/internationalization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"chlbri/gitpod-typescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlbri%2Finternationalization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlbri%2Finternationalization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlbri%2Finternationalization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlbri%2Finternationalization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chlbri","download_url":"https://codeload.github.com/chlbri/internationalization/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246320198,"owners_count":20758410,"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-12-11T18:33:20.747Z","updated_at":"2025-03-30T13:15:30.041Z","avatar_url":"https://github.com/chlbri.png","language":"TypeScript","readme":"V 0.1.1 _Make it browserify_\n\n\u003cbr/\u003e\n\n## Just one class...\n\n\u003cbr/\u003e\u003cbr/\u003e\n\n# Internationalization\n\n\u003cbr/\u003e\u003cbr/\u003e\n\n## Defaut walkthrough\n\n\u003cbr/\u003e\n\n### First create the object with paths (like path.resolve(root, ...parts)) :\n\n```typescript\nconst internationalization = new Internationalization(); // {cwd}/src/locales\nconst internationalization = new Internationalization(\n  'my',\n  'locales',\n  'directory',\n); // Path is resolved with process.cwd() as root\n```\n\n#### NB\n\n1. The default path is {cwd}/src/locales\n2. The locale must have at least a directory (\n   locales/**\u003cu\u003e{locale}\u003c/u\u003e**/common.json )\n3. The locales must be json and can be namespaces (\n   _locales/en/firstPage/header.json_ )\n\n\u003cbr/\u003e\n\n### You can init translations sync\n\n```typescript\nconst internationalization = new Internationalization();\ninternationalization.initSync();\n```\n\n\u003cbr/\u003e\n\n### Or async\n\n```typescript\nconst internationalization = new Internationalization(\n  'my',\n  'locales',\n  'directory',\n);\nawait internationalization.init();\n```\n\n\u003cbr/\u003e\n\n### Then, you can get the string by method : \u003cu\u003egetKey\u003c/u\u003e\n\n```typescript\nconst internationalization = new Internationalization();\ninternationalization.initSync();\ninternationalization.getKey('title'); // =\u003e Title of the page\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Add-ons\n\n\u003cbr/\u003e\n\n### Change Language : \u003cu\u003echangeLanguage\u003c/u\u003e\n\nBy default language is set to English ('en')\n\n```typescript\nconst internationalization = new Internationalization();\ninternationalization.initSync();\ninternationalization.getKey('title'); // =\u003e Title of the page\ninternationalization.changeLanguage('fr');\ninternationalization.getKey('title'); // =\u003e Titre de la page\n```\n\n\u003cbr/\u003e\n\n### Change Default Language : \u003cu\u003eInternationalization.defaultLanguage\u003c/u\u003e\n\nBy default language is set to English ('en')\n\n```typescript\nInternationalization.defaultLanguage = 'fr';\nconst internationalization = new Internationalization();\ninternationalization.initSync();\ninternationalization.getKey('title'); // =\u003e Titre de la page\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\nFor tests, go to repo,\n[here](https://github.com/chlbri/internationalization.git)\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Happy coding 😊❤️😊👨‍💻❤️✅!!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlbri%2Finternationalization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchlbri%2Finternationalization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlbri%2Finternationalization/lists"}