{"id":16374449,"url":"https://github.com/azz/around-the-world","last_synced_at":"2026-03-26T10:30:15.625Z","repository":{"id":57183823,"uuid":"151095389","full_name":"azz/around-the-world","owner":"azz","description":"Simple to use ICU localization library built for MessageFormat","archived":false,"fork":false,"pushed_at":"2018-10-02T02:02:33.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T07:03:24.923Z","etag":null,"topics":["icu","localization","messageformat"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/azz.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":"2018-10-01T13:43:01.000Z","updated_at":"2018-10-02T03:10:51.000Z","dependencies_parsed_at":"2022-08-23T01:31:09.879Z","dependency_job_id":null,"html_url":"https://github.com/azz/around-the-world","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Faround-the-world","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Faround-the-world/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Faround-the-world/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Faround-the-world/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azz","download_url":"https://codeload.github.com/azz/around-the-world/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239946913,"owners_count":19723014,"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":["icu","localization","messageformat"],"created_at":"2024-10-11T03:17:16.531Z","updated_at":"2026-03-26T10:30:15.552Z","avatar_url":"https://github.com/azz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `around-the-world`\n\n[![Travis](https://img.shields.io/travis/azz/around-the-world.svg?style=flat-square)](https://travis-ci.org/azz/around-the-world)\n[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![npm](https://img.shields.io/npm/v/around-the-world.svg?style=flat-square)](https://npmjs.org/around-the-world)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\n\u003e Simple to use ICU localization library built for [MessageFormat][]\n\n`around-the-world` is a utility library built for [MessageFormat][] that makes it it simple to localize your app.\n\n- [x] Lazily loads localization templates.\n- [x] Simple API.\n- [x] Dynamically change the locale.\n\n## Install\n\nWith `yarn`:\n\n```shellsession\nyarn add around-the-world\n```\n\nWith `npm`:\n\n```shellsession\nnpm install --save around-the-world\n```\n\n## Usage\n\n### Loading From a Server\n\nYou can easily fetch string tables from your server using the `loadLocale` function and dynamic imports.\nThe format is expected to be produced by the [MessageFormat][] compiler.\n\n```js\nconst { localize } = await aroundTheWorld({\n  loadLocale: locale =\u003e import(`/i18n/${locale}.js`),\n});\n\nlocalize('hello-world');\n```\n\n### Compiling in the Client\n\nYou can compile ICU messages in the client directly with `MessageFormat#compile`.\n\n```js\nimport aroundTheWorld from 'around-the-world';\nimport MessageFormat from 'messageformat';\n\n(async () =\u003e {\n  const { localize } = await aroundTheWorld({\n    loadLocale: locale =\u003e {\n      if (locale === 'en-US') {\n        const mf = new MessageFormat(locale);\n        return mf.compile({\n          hello_world: 'Hello, world!',\n        });\n      }\n      throw new Error('Unknown locale!');\n    },\n  });\n})();\n```\n\n### Specifying Default Locale\n\nYou can specify the default locale to load using `defaultLocale`. If you don't supply this, [`navigator.language`](https://mdn.io/navigator.language) is used.\n\n```js\nconst { localize } = await aroundTheWorld({\n  loadLocale: locale =\u003e {\n    /* ... */\n  },\n\n  defaultLocale: 'en-AU',\n});\n```\n\n### Changing the Locale\n\nYou can read the current locale at any time by calling `getCurrentLocale()`, and you can set it by calling `setCurrentLocale()`. The latter returns a promise that resolves once the locale is loaded.\n\n```js\nconst { localize, getCurrentLocale, setCurrentLocale } = await aroundTheWorld({\n  loadLocale: locale =\u003e {\n    /* ... */\n  },\n});\n\ngetCurrentLocale(); // 'en-AU'\nlocalize('hello'); // 'Hello'\n\nawait setCurrentLocale('jp');\nlocalize('hello'); // 'こんにちは'\n```\n\n[messageformat]: https://github.com/messageformat/messageformat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Faround-the-world","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazz%2Faround-the-world","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Faround-the-world/lists"}