{"id":20173162,"url":"https://github.com/apitable/apitable-i18n","last_synced_at":"2025-04-10T03:16:52.393Z","repository":{"id":63979948,"uuid":"567655722","full_name":"apitable/apitable-i18n","owner":"apitable","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-23T15:22:28.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T03:16:44.773Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apitable.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":"2022-11-18T09:14:46.000Z","updated_at":"2023-08-12T17:48:08.000Z","dependencies_parsed_at":"2023-01-14T17:15:31.570Z","dependency_job_id":null,"html_url":"https://github.com/apitable/apitable-i18n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apitable%2Fapitable-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apitable%2Fapitable-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apitable%2Fapitable-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apitable%2Fapitable-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apitable","download_url":"https://codeload.github.com/apitable/apitable-i18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248148246,"owners_count":21055548,"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-14T01:34:01.777Z","updated_at":"2025-04-10T03:16:52.377Z","avatar_url":"https://github.com/apitable.png","language":"TypeScript","readme":"# apitable-i18n\n\n`APITable i18n` is a a simple / easy-to-use / lightweight internationalization tool.\n\nIt provides:\n\n- Use APITable to visual edit i18n strings.\n- Use [`APITable Settings Generator`](https://github.com/apitable/apitable-settings-generator) to generate JSON settings.\n- Use `Java` and `TypeScript` SDK as an i18n sdk runtime.\n\n\n`APITable-i18n` has these advantages:\n\n- WYSIWYG: Edit multi-languages on APITable's spreadsheet experience.\n- Slim: Few codes and small.\n- High Performance: Loader separated, support dynamic load easily.\n- Extensible: OOP-design.\n\n## SDKs\nImagine it, you have a `locales.json` file:\n\n```json\n{\n  \"en-US\": {\n    \"text1\": \"This is text 1\",\n    \"text2\": \"This is text 2\"\n  },\n  \"zh-CN\": {\n    \"text1\": \"这是中文1\"\n  }\n}\n```\n\nThen:\n\n\n### TypeScript\n\nInstall APITable i18n :\n```bash\nnpm i --save @apitable/i18n\n```\n\n```typescript\nimport { I18N, ILanguagePackerLoader, ILanguagePack } from '@apitable/i18n';\nconst languagePacks = require('./locales.json');\nconst i18n = I18N.createByLanguagePacks(languagePacks);\ni18n.setLanguage('zh-CN');\nconst res = i18n.getText('text1')\n\nconsole.log(res);\n// will print '这是中文1';\n\n```\n\n\n\n### ~~Java~~\n\n```java\n// build.gradle\ndependencies {\n   compile group: 'com.apitable', name: 'i18n', version: '1.0.0'\n}\n```\n\n\n## Generator\n\nIf you want to integration `@apitable/i18n` with APITable.\n\nGo with [`APITable Settings Generator`](https://github.com/apitable/apitable-settings-generator).\n\n### TODO: 1. APITable Template\n\nYou can get an APITable template that use for your i18n.\n\nhttps://apitable.com/template/i18n\n\n\n### 2. Generate settings\n\nUse [apitable-settings-generator](https://github.com/apitable/apitable-settings-generator) and the `column-files` format to generate i18n languages packs.\n\nThe config.json:\n\n```json\n[\n  {\n    \"dirName\": \"./generated\",\n    \"fileName\": \"locales.*.json\",\n    \"tables\": {\n      {\n        \"datasheetId\": \"dstbUhd5coNXQoXFD8\",\n        \"datasheetName\": \"strings\",\n        \"format\": \"column-files\",\n        \"params\": {}\n      }\n    }\n  }\n]\n```\n\nRun to generate i18n strings:\n\n```bash\n# run in bash\nnpx apitable-settings-generator --config config.json --token ${HERE_IS_YOUR_APITABLE_TOKEN}\n```\n\nGenerated settings locales.en_US.json:\n\n```json\n{\n  \"strings\": {\n    \"en_US\": {\n      \"login_title\": \"Login APITable\",\n      \"some text\": \"some text en_US\"\n    }\n  }\n}\n```\nGenerated settings locales.zh_CN.json:\n\n```json\n{\n  \"strings\": {\n    \"zh_CN\": {\n      \"login_title\": \"中文APITable\",\n      \"some text\": \"some text zh_CN\"\n    }\n  }\n}\n```\n\nThen you will get:\n- locales.json\n- ~~locales.interface.ts(quicktype)~~\n\n\n### TODO: 3. Use SDKs to read them\n\n\n## Development\n\n```\nyarn\nyarn build\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapitable%2Fapitable-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapitable%2Fapitable-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapitable%2Fapitable-i18n/lists"}