{"id":19542597,"url":"https://github.com/fable-compiler/fable.i18next","last_synced_at":"2025-04-26T17:31:21.539Z","repository":{"id":47776483,"uuid":"389416793","full_name":"fable-compiler/Fable.I18Next","owner":"fable-compiler","description":"Fable bindings and helpers for [i18next](https://www.i18next.com/)","archived":false,"fork":false,"pushed_at":"2022-09-27T16:46:07.000Z","size":8603,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T16:41:56.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fable-compiler.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":"2021-07-25T18:36:15.000Z","updated_at":"2022-09-27T14:55:09.000Z","dependencies_parsed_at":"2023-01-18T20:01:54.716Z","dependency_job_id":null,"html_url":"https://github.com/fable-compiler/Fable.I18Next","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2FFable.I18Next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2FFable.I18Next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2FFable.I18Next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2FFable.I18Next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fable-compiler","download_url":"https://codeload.github.com/fable-compiler/Fable.I18Next/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251025759,"owners_count":21524858,"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-11T03:15:17.042Z","updated_at":"2025-04-26T17:31:19.049Z","avatar_url":"https://github.com/fable-compiler.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fable.I18Next\n\nFable bindings and helpers for [i18next](https://www.i18next.com/). The bindings work with Fable and on .NET Core for ServerSide-Rendering.\n\nCreated by [@atheck](https://github.com/atheck).\n\n## Installation\n\n```\nnpm install --save i18next # or\nyarn add i18next\n\npaket add Fable.I18Next --project [yourproject]\n```\n\n## Usage\n\nMake sure your Fable project .fsproj has the `FABLE_COMPILER` property set:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n  \u003cPropertyGroup\u003e\n    \u003cTargetFramework\u003enet5.0\u003c/TargetFramework\u003e\n    \u003cDefineConstants\u003eFABLE_COMPILER\u003c/DefineConstants\u003e\n  \u003c/PropertyGroup\u003e\n  \u003cItemGroup\u003e\n    // ...\n    \u003cCompile Include=\"App.fs\" /\u003e\n  \u003c/ItemGroup\u003e\n\u003c/Project\u003e\n```\n\nCreate a `translations.json` file like the following:\n\n```json\n{\n    \"de\": {\n        \"translation\": {\n            \"MyKey\": \"Das ist ein deutscher Text\"\n        }\n    },\n    \"en\": {\n        \"translation\": {\n        \"MyKey\": \"This is a english text\"\n        }\n    }\n}\n```\n\nHook in Fable.I18Next in your Elmish Program inside App.fs:\n\n```fs\nmodule App\n\nopen Fable.Core.JsInterop\n\n// ...\n\nlet resources : obj = import \"*\" \"./translations.json\"\n\npromise {\n    do! I18n.Init(resources,\"en\")\n    Program.run program\n}\n|\u003e Promise.start\n\n\n```\n\nIf you want to access the translation then just use:\n\n```fs\n\nopen Fable.I18Next\n\nI18n.Translate \"MyKey\"\n\n```\n\nIf you want to switch the language then use the `I18n.ChangeLanguage`. If you use Elmish then you can put it into a Cmd:\n\n```fs\n\nopen Fable.I18Next\n\nlet update msg model =\n    match msg with\n    // ...\n    | ChangeLanguage newLanguage -\u003e\n        model, Cmd.OfPromise.either I18n.ChangeLanguage newLanguage LanguageChanged Error\n    // ...\n\n```\n\n### Usage on .NET Core\n\n```fs\nlet resourceFileName =\n    let app = System.Reflection.Assembly.GetExecutingAssembly().Location\n    let startupPath = System.IO.Path.GetDirectoryName app\n    Path.Combine(startupPath, \"translations.json\")\n\nI18n.Init(resourceFileName, initialLang)\n```\n\nPlease read the [i18next docs](https://www.i18next.com/) for more sophisticated examples.\n\n## Release process\n\nAfter installing dependencies with `yarn install`, run `yarn run build publish` to publish a new package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffable-compiler%2Ffable.i18next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffable-compiler%2Ffable.i18next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffable-compiler%2Ffable.i18next/lists"}