@tracearr/translations 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +116 -0
- package/dist/config.d.ts +4510 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +164 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mobile.d.ts +4511 -0
- package/dist/config.mobile.d.ts.map +1 -0
- package/dist/config.mobile.js +587 -0
- package/dist/config.mobile.js.map +1 -0
- package/dist/formatting.d.ts +120 -0
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +265 -0
- package/dist/formatting.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/language.d.ts +101 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +241 -0
- package/dist/language.js.map +1 -0
- package/dist/locales/af/common.json +276 -0
- package/dist/locales/af/mobile.json +60 -0
- package/dist/locales/af/nav.json +22 -0
- package/dist/locales/af/notifications.json +262 -0
- package/dist/locales/af/pages.json +324 -0
- package/dist/locales/af/settings.json +243 -0
- package/dist/locales/af-ZA/common.json +308 -0
- package/dist/locales/af-ZA/mobile.json +178 -0
- package/dist/locales/af-ZA/nav.json +28 -0
- package/dist/locales/af-ZA/notifications.json +279 -0
- package/dist/locales/af-ZA/pages.json +953 -0
- package/dist/locales/af-ZA/settings.json +487 -0
- package/dist/locales/ar/common.json +276 -0
- package/dist/locales/ar/mobile.json +60 -0
- package/dist/locales/ar/nav.json +22 -0
- package/dist/locales/ar/notifications.json +262 -0
- package/dist/locales/ar/pages.json +324 -0
- package/dist/locales/ar/settings.json +243 -0
- package/dist/locales/ar-SA/common.json +308 -0
- package/dist/locales/ar-SA/mobile.json +178 -0
- package/dist/locales/ar-SA/nav.json +28 -0
- package/dist/locales/ar-SA/notifications.json +279 -0
- package/dist/locales/ar-SA/pages.json +953 -0
- package/dist/locales/ar-SA/settings.json +487 -0
- package/dist/locales/ca/common.json +276 -0
- package/dist/locales/ca/mobile.json +60 -0
- package/dist/locales/ca/nav.json +22 -0
- package/dist/locales/ca/notifications.json +262 -0
- package/dist/locales/ca/pages.json +324 -0
- package/dist/locales/ca/settings.json +243 -0
- package/dist/locales/ca-ES/common.json +308 -0
- package/dist/locales/ca-ES/mobile.json +178 -0
- package/dist/locales/ca-ES/nav.json +28 -0
- package/dist/locales/ca-ES/notifications.json +279 -0
- package/dist/locales/ca-ES/pages.json +953 -0
- package/dist/locales/ca-ES/settings.json +487 -0
- package/dist/locales/cs/common.json +276 -0
- package/dist/locales/cs/mobile.json +60 -0
- package/dist/locales/cs/nav.json +22 -0
- package/dist/locales/cs/notifications.json +262 -0
- package/dist/locales/cs/pages.json +324 -0
- package/dist/locales/cs/settings.json +243 -0
- package/dist/locales/cs-CZ/common.json +308 -0
- package/dist/locales/cs-CZ/mobile.json +178 -0
- package/dist/locales/cs-CZ/nav.json +28 -0
- package/dist/locales/cs-CZ/notifications.json +279 -0
- package/dist/locales/cs-CZ/pages.json +953 -0
- package/dist/locales/cs-CZ/settings.json +487 -0
- package/dist/locales/da/common.json +276 -0
- package/dist/locales/da/mobile.json +60 -0
- package/dist/locales/da/nav.json +22 -0
- package/dist/locales/da/notifications.json +262 -0
- package/dist/locales/da/pages.json +324 -0
- package/dist/locales/da/settings.json +243 -0
- package/dist/locales/da-DK/common.json +308 -0
- package/dist/locales/da-DK/mobile.json +178 -0
- package/dist/locales/da-DK/nav.json +28 -0
- package/dist/locales/da-DK/notifications.json +279 -0
- package/dist/locales/da-DK/pages.json +953 -0
- package/dist/locales/da-DK/settings.json +487 -0
- package/dist/locales/de/common.json +276 -0
- package/dist/locales/de/mobile.json +60 -0
- package/dist/locales/de/nav.json +22 -0
- package/dist/locales/de/notifications.json +262 -0
- package/dist/locales/de/pages.json +324 -0
- package/dist/locales/de/settings.json +243 -0
- package/dist/locales/de-DE/common.json +308 -0
- package/dist/locales/de-DE/mobile.json +178 -0
- package/dist/locales/de-DE/nav.json +28 -0
- package/dist/locales/de-DE/notifications.json +279 -0
- package/dist/locales/de-DE/pages.json +953 -0
- package/dist/locales/de-DE/settings.json +487 -0
- package/dist/locales/el/common.json +276 -0
- package/dist/locales/el/mobile.json +60 -0
- package/dist/locales/el/nav.json +22 -0
- package/dist/locales/el/notifications.json +262 -0
- package/dist/locales/el/pages.json +324 -0
- package/dist/locales/el/settings.json +243 -0
- package/dist/locales/el-GR/common.json +308 -0
- package/dist/locales/el-GR/mobile.json +178 -0
- package/dist/locales/el-GR/nav.json +28 -0
- package/dist/locales/el-GR/notifications.json +279 -0
- package/dist/locales/el-GR/pages.json +953 -0
- package/dist/locales/el-GR/settings.json +487 -0
- package/dist/locales/en/common.json +308 -0
- package/dist/locales/en/mobile.json +178 -0
- package/dist/locales/en/nav.json +28 -0
- package/dist/locales/en/notifications.json +279 -0
- package/dist/locales/en/pages.json +953 -0
- package/dist/locales/en/settings.json +487 -0
- package/dist/locales/en-US/common.json +308 -0
- package/dist/locales/en-US/mobile.json +178 -0
- package/dist/locales/en-US/nav.json +28 -0
- package/dist/locales/en-US/notifications.json +279 -0
- package/dist/locales/en-US/pages.json +953 -0
- package/dist/locales/en-US/settings.json +487 -0
- package/dist/locales/es/common.json +276 -0
- package/dist/locales/es/mobile.json +60 -0
- package/dist/locales/es/nav.json +22 -0
- package/dist/locales/es/notifications.json +262 -0
- package/dist/locales/es/pages.json +324 -0
- package/dist/locales/es/settings.json +243 -0
- package/dist/locales/es-ES/common.json +308 -0
- package/dist/locales/es-ES/mobile.json +178 -0
- package/dist/locales/es-ES/nav.json +28 -0
- package/dist/locales/es-ES/notifications.json +279 -0
- package/dist/locales/es-ES/pages.json +953 -0
- package/dist/locales/es-ES/settings.json +487 -0
- package/dist/locales/fi/common.json +276 -0
- package/dist/locales/fi/mobile.json +60 -0
- package/dist/locales/fi/nav.json +22 -0
- package/dist/locales/fi/notifications.json +262 -0
- package/dist/locales/fi/pages.json +324 -0
- package/dist/locales/fi/settings.json +243 -0
- package/dist/locales/fi-FI/common.json +308 -0
- package/dist/locales/fi-FI/mobile.json +178 -0
- package/dist/locales/fi-FI/nav.json +28 -0
- package/dist/locales/fi-FI/notifications.json +279 -0
- package/dist/locales/fi-FI/pages.json +953 -0
- package/dist/locales/fi-FI/settings.json +487 -0
- package/dist/locales/fr/common.json +276 -0
- package/dist/locales/fr/mobile.json +60 -0
- package/dist/locales/fr/nav.json +22 -0
- package/dist/locales/fr/notifications.json +262 -0
- package/dist/locales/fr/pages.json +324 -0
- package/dist/locales/fr/settings.json +243 -0
- package/dist/locales/fr-FR/common.json +308 -0
- package/dist/locales/fr-FR/mobile.json +178 -0
- package/dist/locales/fr-FR/nav.json +28 -0
- package/dist/locales/fr-FR/notifications.json +279 -0
- package/dist/locales/fr-FR/pages.json +953 -0
- package/dist/locales/fr-FR/settings.json +487 -0
- package/dist/locales/he/common.json +276 -0
- package/dist/locales/he/mobile.json +60 -0
- package/dist/locales/he/nav.json +22 -0
- package/dist/locales/he/notifications.json +262 -0
- package/dist/locales/he/pages.json +324 -0
- package/dist/locales/he/settings.json +243 -0
- package/dist/locales/he-IL/common.json +308 -0
- package/dist/locales/he-IL/mobile.json +178 -0
- package/dist/locales/he-IL/nav.json +28 -0
- package/dist/locales/he-IL/notifications.json +279 -0
- package/dist/locales/he-IL/pages.json +953 -0
- package/dist/locales/he-IL/settings.json +487 -0
- package/dist/locales/hu/common.json +276 -0
- package/dist/locales/hu/mobile.json +60 -0
- package/dist/locales/hu/nav.json +22 -0
- package/dist/locales/hu/notifications.json +262 -0
- package/dist/locales/hu/pages.json +324 -0
- package/dist/locales/hu/settings.json +243 -0
- package/dist/locales/hu-HU/common.json +308 -0
- package/dist/locales/hu-HU/mobile.json +178 -0
- package/dist/locales/hu-HU/nav.json +28 -0
- package/dist/locales/hu-HU/notifications.json +279 -0
- package/dist/locales/hu-HU/pages.json +953 -0
- package/dist/locales/hu-HU/settings.json +487 -0
- package/dist/locales/it/common.json +276 -0
- package/dist/locales/it/mobile.json +60 -0
- package/dist/locales/it/nav.json +22 -0
- package/dist/locales/it/notifications.json +262 -0
- package/dist/locales/it/pages.json +324 -0
- package/dist/locales/it/settings.json +243 -0
- package/dist/locales/it-IT/common.json +308 -0
- package/dist/locales/it-IT/mobile.json +178 -0
- package/dist/locales/it-IT/nav.json +28 -0
- package/dist/locales/it-IT/notifications.json +279 -0
- package/dist/locales/it-IT/pages.json +953 -0
- package/dist/locales/it-IT/settings.json +487 -0
- package/dist/locales/ja/common.json +276 -0
- package/dist/locales/ja/mobile.json +60 -0
- package/dist/locales/ja/nav.json +22 -0
- package/dist/locales/ja/notifications.json +262 -0
- package/dist/locales/ja/pages.json +324 -0
- package/dist/locales/ja/settings.json +243 -0
- package/dist/locales/ja-JP/common.json +308 -0
- package/dist/locales/ja-JP/mobile.json +178 -0
- package/dist/locales/ja-JP/nav.json +28 -0
- package/dist/locales/ja-JP/notifications.json +279 -0
- package/dist/locales/ja-JP/pages.json +953 -0
- package/dist/locales/ja-JP/settings.json +487 -0
- package/dist/locales/ko/common.json +276 -0
- package/dist/locales/ko/mobile.json +60 -0
- package/dist/locales/ko/nav.json +22 -0
- package/dist/locales/ko/notifications.json +262 -0
- package/dist/locales/ko/pages.json +324 -0
- package/dist/locales/ko/settings.json +243 -0
- package/dist/locales/ko-KR/common.json +308 -0
- package/dist/locales/ko-KR/mobile.json +178 -0
- package/dist/locales/ko-KR/nav.json +28 -0
- package/dist/locales/ko-KR/notifications.json +279 -0
- package/dist/locales/ko-KR/pages.json +953 -0
- package/dist/locales/ko-KR/settings.json +487 -0
- package/dist/locales/nl/common.json +276 -0
- package/dist/locales/nl/mobile.json +60 -0
- package/dist/locales/nl/nav.json +22 -0
- package/dist/locales/nl/notifications.json +262 -0
- package/dist/locales/nl/pages.json +324 -0
- package/dist/locales/nl/settings.json +243 -0
- package/dist/locales/nl-NL/common.json +308 -0
- package/dist/locales/nl-NL/mobile.json +178 -0
- package/dist/locales/nl-NL/nav.json +28 -0
- package/dist/locales/nl-NL/notifications.json +279 -0
- package/dist/locales/nl-NL/pages.json +953 -0
- package/dist/locales/nl-NL/settings.json +487 -0
- package/dist/locales/no/common.json +276 -0
- package/dist/locales/no/mobile.json +60 -0
- package/dist/locales/no/nav.json +22 -0
- package/dist/locales/no/notifications.json +262 -0
- package/dist/locales/no/pages.json +324 -0
- package/dist/locales/no/settings.json +243 -0
- package/dist/locales/no-NO/common.json +308 -0
- package/dist/locales/no-NO/mobile.json +178 -0
- package/dist/locales/no-NO/nav.json +28 -0
- package/dist/locales/no-NO/notifications.json +279 -0
- package/dist/locales/no-NO/pages.json +953 -0
- package/dist/locales/no-NO/settings.json +487 -0
- package/dist/locales/pl/common.json +276 -0
- package/dist/locales/pl/mobile.json +60 -0
- package/dist/locales/pl/nav.json +22 -0
- package/dist/locales/pl/notifications.json +262 -0
- package/dist/locales/pl/pages.json +324 -0
- package/dist/locales/pl/settings.json +243 -0
- package/dist/locales/pl-PL/common.json +308 -0
- package/dist/locales/pl-PL/mobile.json +178 -0
- package/dist/locales/pl-PL/nav.json +28 -0
- package/dist/locales/pl-PL/notifications.json +279 -0
- package/dist/locales/pl-PL/pages.json +953 -0
- package/dist/locales/pl-PL/settings.json +487 -0
- package/dist/locales/pt/common.json +276 -0
- package/dist/locales/pt/mobile.json +60 -0
- package/dist/locales/pt/nav.json +22 -0
- package/dist/locales/pt/notifications.json +262 -0
- package/dist/locales/pt/pages.json +324 -0
- package/dist/locales/pt/settings.json +243 -0
- package/dist/locales/pt-BR/common.json +308 -0
- package/dist/locales/pt-BR/mobile.json +178 -0
- package/dist/locales/pt-BR/nav.json +28 -0
- package/dist/locales/pt-BR/notifications.json +279 -0
- package/dist/locales/pt-BR/pages.json +953 -0
- package/dist/locales/pt-BR/settings.json +487 -0
- package/dist/locales/pt-PT/common.json +308 -0
- package/dist/locales/pt-PT/mobile.json +178 -0
- package/dist/locales/pt-PT/nav.json +28 -0
- package/dist/locales/pt-PT/notifications.json +279 -0
- package/dist/locales/pt-PT/pages.json +953 -0
- package/dist/locales/pt-PT/settings.json +487 -0
- package/dist/locales/ro/common.json +276 -0
- package/dist/locales/ro/mobile.json +60 -0
- package/dist/locales/ro/nav.json +22 -0
- package/dist/locales/ro/notifications.json +262 -0
- package/dist/locales/ro/pages.json +324 -0
- package/dist/locales/ro/settings.json +243 -0
- package/dist/locales/ro-RO/common.json +308 -0
- package/dist/locales/ro-RO/mobile.json +178 -0
- package/dist/locales/ro-RO/nav.json +28 -0
- package/dist/locales/ro-RO/notifications.json +279 -0
- package/dist/locales/ro-RO/pages.json +953 -0
- package/dist/locales/ro-RO/settings.json +487 -0
- package/dist/locales/ru/common.json +276 -0
- package/dist/locales/ru/mobile.json +60 -0
- package/dist/locales/ru/nav.json +22 -0
- package/dist/locales/ru/notifications.json +262 -0
- package/dist/locales/ru/pages.json +324 -0
- package/dist/locales/ru/settings.json +243 -0
- package/dist/locales/ru-RU/common.json +308 -0
- package/dist/locales/ru-RU/mobile.json +178 -0
- package/dist/locales/ru-RU/nav.json +28 -0
- package/dist/locales/ru-RU/notifications.json +279 -0
- package/dist/locales/ru-RU/pages.json +953 -0
- package/dist/locales/ru-RU/settings.json +487 -0
- package/dist/locales/sr/common.json +276 -0
- package/dist/locales/sr/mobile.json +60 -0
- package/dist/locales/sr/nav.json +22 -0
- package/dist/locales/sr/notifications.json +262 -0
- package/dist/locales/sr/pages.json +324 -0
- package/dist/locales/sr/settings.json +243 -0
- package/dist/locales/sr-SP/common.json +308 -0
- package/dist/locales/sr-SP/mobile.json +178 -0
- package/dist/locales/sr-SP/nav.json +28 -0
- package/dist/locales/sr-SP/notifications.json +279 -0
- package/dist/locales/sr-SP/pages.json +953 -0
- package/dist/locales/sr-SP/settings.json +487 -0
- package/dist/locales/sv/common.json +276 -0
- package/dist/locales/sv/mobile.json +60 -0
- package/dist/locales/sv/nav.json +22 -0
- package/dist/locales/sv/notifications.json +262 -0
- package/dist/locales/sv/pages.json +324 -0
- package/dist/locales/sv/settings.json +243 -0
- package/dist/locales/sv-SE/common.json +308 -0
- package/dist/locales/sv-SE/mobile.json +178 -0
- package/dist/locales/sv-SE/nav.json +28 -0
- package/dist/locales/sv-SE/notifications.json +279 -0
- package/dist/locales/sv-SE/pages.json +953 -0
- package/dist/locales/sv-SE/settings.json +487 -0
- package/dist/locales/tr/common.json +276 -0
- package/dist/locales/tr/mobile.json +60 -0
- package/dist/locales/tr/nav.json +22 -0
- package/dist/locales/tr/notifications.json +262 -0
- package/dist/locales/tr/pages.json +324 -0
- package/dist/locales/tr/settings.json +243 -0
- package/dist/locales/tr-TR/common.json +308 -0
- package/dist/locales/tr-TR/mobile.json +178 -0
- package/dist/locales/tr-TR/nav.json +28 -0
- package/dist/locales/tr-TR/notifications.json +279 -0
- package/dist/locales/tr-TR/pages.json +953 -0
- package/dist/locales/tr-TR/settings.json +487 -0
- package/dist/locales/uk/common.json +276 -0
- package/dist/locales/uk/mobile.json +60 -0
- package/dist/locales/uk/nav.json +22 -0
- package/dist/locales/uk/notifications.json +262 -0
- package/dist/locales/uk/pages.json +324 -0
- package/dist/locales/uk/settings.json +243 -0
- package/dist/locales/uk-UA/common.json +308 -0
- package/dist/locales/uk-UA/mobile.json +178 -0
- package/dist/locales/uk-UA/nav.json +28 -0
- package/dist/locales/uk-UA/notifications.json +279 -0
- package/dist/locales/uk-UA/pages.json +953 -0
- package/dist/locales/uk-UA/settings.json +487 -0
- package/dist/locales/vi/common.json +276 -0
- package/dist/locales/vi/mobile.json +60 -0
- package/dist/locales/vi/nav.json +22 -0
- package/dist/locales/vi/notifications.json +262 -0
- package/dist/locales/vi/pages.json +324 -0
- package/dist/locales/vi/settings.json +243 -0
- package/dist/locales/vi-VN/common.json +308 -0
- package/dist/locales/vi-VN/mobile.json +178 -0
- package/dist/locales/vi-VN/nav.json +28 -0
- package/dist/locales/vi-VN/notifications.json +279 -0
- package/dist/locales/vi-VN/pages.json +953 -0
- package/dist/locales/vi-VN/settings.json +487 -0
- package/dist/locales/zh/common.json +276 -0
- package/dist/locales/zh/mobile.json +60 -0
- package/dist/locales/zh/nav.json +22 -0
- package/dist/locales/zh/notifications.json +262 -0
- package/dist/locales/zh/pages.json +324 -0
- package/dist/locales/zh/settings.json +243 -0
- package/dist/locales/zh-CN/common.json +308 -0
- package/dist/locales/zh-CN/mobile.json +178 -0
- package/dist/locales/zh-CN/nav.json +28 -0
- package/dist/locales/zh-CN/notifications.json +279 -0
- package/dist/locales/zh-CN/pages.json +953 -0
- package/dist/locales/zh-CN/settings.json +487 -0
- package/dist/locales/zh-TW/common.json +308 -0
- package/dist/locales/zh-TW/mobile.json +178 -0
- package/dist/locales/zh-TW/nav.json +28 -0
- package/dist/locales/zh-TW/notifications.json +279 -0
- package/dist/locales/zh-TW/pages.json +953 -0
- package/dist/locales/zh-TW/settings.json +487 -0
- package/dist/mobile.d.ts +11 -0
- package/dist/mobile.d.ts.map +1 -0
- package/dist/mobile.js +14 -0
- package/dist/mobile.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
- package/src/config.mobile.ts +647 -0
- package/src/config.ts +209 -0
- package/src/formatting.ts +297 -0
- package/src/index.ts +105 -0
- package/src/language.ts +270 -0
- package/src/locales/af-ZA/common.json +308 -0
- package/src/locales/af-ZA/mobile.json +178 -0
- package/src/locales/af-ZA/nav.json +28 -0
- package/src/locales/af-ZA/notifications.json +279 -0
- package/src/locales/af-ZA/pages.json +953 -0
- package/src/locales/af-ZA/settings.json +487 -0
- package/src/locales/ar-SA/common.json +308 -0
- package/src/locales/ar-SA/mobile.json +178 -0
- package/src/locales/ar-SA/nav.json +28 -0
- package/src/locales/ar-SA/notifications.json +279 -0
- package/src/locales/ar-SA/pages.json +953 -0
- package/src/locales/ar-SA/settings.json +487 -0
- package/src/locales/ca-ES/common.json +308 -0
- package/src/locales/ca-ES/mobile.json +178 -0
- package/src/locales/ca-ES/nav.json +28 -0
- package/src/locales/ca-ES/notifications.json +279 -0
- package/src/locales/ca-ES/pages.json +953 -0
- package/src/locales/ca-ES/settings.json +487 -0
- package/src/locales/cs-CZ/common.json +308 -0
- package/src/locales/cs-CZ/mobile.json +178 -0
- package/src/locales/cs-CZ/nav.json +28 -0
- package/src/locales/cs-CZ/notifications.json +279 -0
- package/src/locales/cs-CZ/pages.json +953 -0
- package/src/locales/cs-CZ/settings.json +487 -0
- package/src/locales/da-DK/common.json +308 -0
- package/src/locales/da-DK/mobile.json +178 -0
- package/src/locales/da-DK/nav.json +28 -0
- package/src/locales/da-DK/notifications.json +279 -0
- package/src/locales/da-DK/pages.json +953 -0
- package/src/locales/da-DK/settings.json +487 -0
- package/src/locales/de-DE/common.json +308 -0
- package/src/locales/de-DE/mobile.json +178 -0
- package/src/locales/de-DE/nav.json +28 -0
- package/src/locales/de-DE/notifications.json +279 -0
- package/src/locales/de-DE/pages.json +953 -0
- package/src/locales/de-DE/settings.json +487 -0
- package/src/locales/el-GR/common.json +308 -0
- package/src/locales/el-GR/mobile.json +178 -0
- package/src/locales/el-GR/nav.json +28 -0
- package/src/locales/el-GR/notifications.json +279 -0
- package/src/locales/el-GR/pages.json +953 -0
- package/src/locales/el-GR/settings.json +487 -0
- package/src/locales/en/common.json +308 -0
- package/src/locales/en/mobile.json +178 -0
- package/src/locales/en/nav.json +28 -0
- package/src/locales/en/notifications.json +279 -0
- package/src/locales/en/pages.json +953 -0
- package/src/locales/en/settings.json +487 -0
- package/src/locales/en-US/common.json +308 -0
- package/src/locales/en-US/mobile.json +178 -0
- package/src/locales/en-US/nav.json +28 -0
- package/src/locales/en-US/notifications.json +279 -0
- package/src/locales/en-US/pages.json +953 -0
- package/src/locales/en-US/settings.json +487 -0
- package/src/locales/es-ES/common.json +308 -0
- package/src/locales/es-ES/mobile.json +178 -0
- package/src/locales/es-ES/nav.json +28 -0
- package/src/locales/es-ES/notifications.json +279 -0
- package/src/locales/es-ES/pages.json +953 -0
- package/src/locales/es-ES/settings.json +487 -0
- package/src/locales/fi-FI/common.json +308 -0
- package/src/locales/fi-FI/mobile.json +178 -0
- package/src/locales/fi-FI/nav.json +28 -0
- package/src/locales/fi-FI/notifications.json +279 -0
- package/src/locales/fi-FI/pages.json +953 -0
- package/src/locales/fi-FI/settings.json +487 -0
- package/src/locales/fr-FR/common.json +308 -0
- package/src/locales/fr-FR/mobile.json +178 -0
- package/src/locales/fr-FR/nav.json +28 -0
- package/src/locales/fr-FR/notifications.json +279 -0
- package/src/locales/fr-FR/pages.json +953 -0
- package/src/locales/fr-FR/settings.json +487 -0
- package/src/locales/he-IL/common.json +308 -0
- package/src/locales/he-IL/mobile.json +178 -0
- package/src/locales/he-IL/nav.json +28 -0
- package/src/locales/he-IL/notifications.json +279 -0
- package/src/locales/he-IL/pages.json +953 -0
- package/src/locales/he-IL/settings.json +487 -0
- package/src/locales/hu-HU/common.json +308 -0
- package/src/locales/hu-HU/mobile.json +178 -0
- package/src/locales/hu-HU/nav.json +28 -0
- package/src/locales/hu-HU/notifications.json +279 -0
- package/src/locales/hu-HU/pages.json +953 -0
- package/src/locales/hu-HU/settings.json +487 -0
- package/src/locales/it-IT/common.json +308 -0
- package/src/locales/it-IT/mobile.json +178 -0
- package/src/locales/it-IT/nav.json +28 -0
- package/src/locales/it-IT/notifications.json +279 -0
- package/src/locales/it-IT/pages.json +953 -0
- package/src/locales/it-IT/settings.json +487 -0
- package/src/locales/ja-JP/common.json +308 -0
- package/src/locales/ja-JP/mobile.json +178 -0
- package/src/locales/ja-JP/nav.json +28 -0
- package/src/locales/ja-JP/notifications.json +279 -0
- package/src/locales/ja-JP/pages.json +953 -0
- package/src/locales/ja-JP/settings.json +487 -0
- package/src/locales/ko-KR/common.json +308 -0
- package/src/locales/ko-KR/mobile.json +178 -0
- package/src/locales/ko-KR/nav.json +28 -0
- package/src/locales/ko-KR/notifications.json +279 -0
- package/src/locales/ko-KR/pages.json +953 -0
- package/src/locales/ko-KR/settings.json +487 -0
- package/src/locales/nl-NL/common.json +308 -0
- package/src/locales/nl-NL/mobile.json +178 -0
- package/src/locales/nl-NL/nav.json +28 -0
- package/src/locales/nl-NL/notifications.json +279 -0
- package/src/locales/nl-NL/pages.json +953 -0
- package/src/locales/nl-NL/settings.json +487 -0
- package/src/locales/no-NO/common.json +308 -0
- package/src/locales/no-NO/mobile.json +178 -0
- package/src/locales/no-NO/nav.json +28 -0
- package/src/locales/no-NO/notifications.json +279 -0
- package/src/locales/no-NO/pages.json +953 -0
- package/src/locales/no-NO/settings.json +487 -0
- package/src/locales/pl-PL/common.json +308 -0
- package/src/locales/pl-PL/mobile.json +178 -0
- package/src/locales/pl-PL/nav.json +28 -0
- package/src/locales/pl-PL/notifications.json +279 -0
- package/src/locales/pl-PL/pages.json +953 -0
- package/src/locales/pl-PL/settings.json +487 -0
- package/src/locales/pt-BR/common.json +308 -0
- package/src/locales/pt-BR/mobile.json +178 -0
- package/src/locales/pt-BR/nav.json +28 -0
- package/src/locales/pt-BR/notifications.json +279 -0
- package/src/locales/pt-BR/pages.json +953 -0
- package/src/locales/pt-BR/settings.json +487 -0
- package/src/locales/pt-PT/common.json +308 -0
- package/src/locales/pt-PT/mobile.json +178 -0
- package/src/locales/pt-PT/nav.json +28 -0
- package/src/locales/pt-PT/notifications.json +279 -0
- package/src/locales/pt-PT/pages.json +953 -0
- package/src/locales/pt-PT/settings.json +487 -0
- package/src/locales/ro-RO/common.json +308 -0
- package/src/locales/ro-RO/mobile.json +178 -0
- package/src/locales/ro-RO/nav.json +28 -0
- package/src/locales/ro-RO/notifications.json +279 -0
- package/src/locales/ro-RO/pages.json +953 -0
- package/src/locales/ro-RO/settings.json +487 -0
- package/src/locales/ru-RU/common.json +308 -0
- package/src/locales/ru-RU/mobile.json +178 -0
- package/src/locales/ru-RU/nav.json +28 -0
- package/src/locales/ru-RU/notifications.json +279 -0
- package/src/locales/ru-RU/pages.json +953 -0
- package/src/locales/ru-RU/settings.json +487 -0
- package/src/locales/sr-SP/common.json +308 -0
- package/src/locales/sr-SP/mobile.json +178 -0
- package/src/locales/sr-SP/nav.json +28 -0
- package/src/locales/sr-SP/notifications.json +279 -0
- package/src/locales/sr-SP/pages.json +953 -0
- package/src/locales/sr-SP/settings.json +487 -0
- package/src/locales/sv-SE/common.json +308 -0
- package/src/locales/sv-SE/mobile.json +178 -0
- package/src/locales/sv-SE/nav.json +28 -0
- package/src/locales/sv-SE/notifications.json +279 -0
- package/src/locales/sv-SE/pages.json +953 -0
- package/src/locales/sv-SE/settings.json +487 -0
- package/src/locales/tr-TR/common.json +308 -0
- package/src/locales/tr-TR/mobile.json +178 -0
- package/src/locales/tr-TR/nav.json +28 -0
- package/src/locales/tr-TR/notifications.json +279 -0
- package/src/locales/tr-TR/pages.json +953 -0
- package/src/locales/tr-TR/settings.json +487 -0
- package/src/locales/uk-UA/common.json +308 -0
- package/src/locales/uk-UA/mobile.json +178 -0
- package/src/locales/uk-UA/nav.json +28 -0
- package/src/locales/uk-UA/notifications.json +279 -0
- package/src/locales/uk-UA/pages.json +953 -0
- package/src/locales/uk-UA/settings.json +487 -0
- package/src/locales/vi-VN/common.json +308 -0
- package/src/locales/vi-VN/mobile.json +178 -0
- package/src/locales/vi-VN/nav.json +28 -0
- package/src/locales/vi-VN/notifications.json +279 -0
- package/src/locales/vi-VN/pages.json +953 -0
- package/src/locales/vi-VN/settings.json +487 -0
- package/src/locales/zh-CN/common.json +308 -0
- package/src/locales/zh-CN/mobile.json +178 -0
- package/src/locales/zh-CN/nav.json +28 -0
- package/src/locales/zh-CN/notifications.json +279 -0
- package/src/locales/zh-CN/pages.json +953 -0
- package/src/locales/zh-CN/settings.json +487 -0
- package/src/locales/zh-TW/common.json +308 -0
- package/src/locales/zh-TW/mobile.json +178 -0
- package/src/locales/zh-TW/nav.json +28 -0
- package/src/locales/zh-TW/notifications.json +279 -0
- package/src/locales/zh-TW/pages.json +953 -0
- package/src/locales/zh-TW/settings.json +487 -0
- package/src/mobile.ts +69 -0
- package/src/types.ts +86 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date, time, and number formatting utilities.
|
|
3
|
+
*
|
|
4
|
+
* Uses the native Intl API for locale-aware formatting.
|
|
5
|
+
* Works consistently across web and React Native environments.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Format options for dates and times.
|
|
9
|
+
*/
|
|
10
|
+
export type DateFormatStyle = 'short' | 'medium' | 'long' | 'full';
|
|
11
|
+
/**
|
|
12
|
+
* Format a date using the current locale.
|
|
13
|
+
*
|
|
14
|
+
* @param date - Date to format
|
|
15
|
+
* @param style - Format style ('short', 'medium', 'long', 'full')
|
|
16
|
+
* @returns Formatted date string
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* formatDate(new Date(), 'short') // "1/2/26" (en-US)
|
|
20
|
+
* formatDate(new Date(), 'long') // "January 2, 2026" (en-US)
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatDate(date: Date | number, style?: DateFormatStyle): string;
|
|
23
|
+
/**
|
|
24
|
+
* Format a time using the current locale.
|
|
25
|
+
*
|
|
26
|
+
* @param date - Date to format
|
|
27
|
+
* @param style - Format style ('short', 'medium', 'long', 'full')
|
|
28
|
+
* @returns Formatted time string
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* formatTime(new Date(), 'short') // "3:30 PM" (en-US)
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatTime(date: Date | number, style?: DateFormatStyle): string;
|
|
34
|
+
/**
|
|
35
|
+
* Format a date and time using the current locale.
|
|
36
|
+
*
|
|
37
|
+
* @param date - Date to format
|
|
38
|
+
* @param dateStyle - Date format style
|
|
39
|
+
* @param timeStyle - Time format style
|
|
40
|
+
* @returns Formatted datetime string
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* formatDateTime(new Date(), 'short', 'short') // "1/2/26, 3:30 PM" (en-US)
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatDateTime(date: Date | number, dateStyle?: DateFormatStyle, timeStyle?: DateFormatStyle): string;
|
|
46
|
+
/**
|
|
47
|
+
* Format a relative time (e.g., "2 hours ago", "in 3 days").
|
|
48
|
+
*
|
|
49
|
+
* @param date - Date to compare to now
|
|
50
|
+
* @param now - Reference time (defaults to current time)
|
|
51
|
+
* @returns Formatted relative time string
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* formatRelativeTime(Date.now() - 3600000) // "1 hour ago"
|
|
55
|
+
* formatRelativeTime(Date.now() + 86400000) // "in 1 day"
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatRelativeTime(date: Date | number, now?: Date | number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Format a duration in milliseconds to a human-readable string.
|
|
60
|
+
*
|
|
61
|
+
* @param ms - Duration in milliseconds
|
|
62
|
+
* @param options - Formatting options
|
|
63
|
+
* @returns Formatted duration string
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* formatDuration(3661000) // "1h 1m 1s"
|
|
67
|
+
* formatDuration(3661000, { style: 'long' }) // "1 hour, 1 minute, 1 second"
|
|
68
|
+
*/
|
|
69
|
+
export declare function formatDuration(ms: number, options?: {
|
|
70
|
+
style?: 'short' | 'long';
|
|
71
|
+
maxUnits?: number;
|
|
72
|
+
}): string;
|
|
73
|
+
/**
|
|
74
|
+
* Format a number using the current locale.
|
|
75
|
+
*
|
|
76
|
+
* @param value - Number to format
|
|
77
|
+
* @param options - Intl.NumberFormat options
|
|
78
|
+
* @returns Formatted number string
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* formatNumber(1234567.89) // "1,234,567.89" (en-US)
|
|
82
|
+
*/
|
|
83
|
+
export declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
84
|
+
/**
|
|
85
|
+
* Format a number as a percentage.
|
|
86
|
+
*
|
|
87
|
+
* @param value - Number to format (0-1 or 0-100 depending on usePercent)
|
|
88
|
+
* @param decimals - Number of decimal places
|
|
89
|
+
* @param usePercent - If true, value is already a percentage (0-100)
|
|
90
|
+
* @returns Formatted percentage string
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* formatPercent(0.75) // "75%"
|
|
94
|
+
* formatPercent(75, 1, true) // "75.0%"
|
|
95
|
+
*/
|
|
96
|
+
export declare function formatPercent(value: number, decimals?: number, usePercent?: boolean): string;
|
|
97
|
+
/**
|
|
98
|
+
* Format bytes to a human-readable size string.
|
|
99
|
+
*
|
|
100
|
+
* @param bytes - Number of bytes
|
|
101
|
+
* @param decimals - Number of decimal places
|
|
102
|
+
* @returns Formatted size string
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* formatBytes(1024) // "1 KB"
|
|
106
|
+
* formatBytes(1536, 1) // "1.5 KB"
|
|
107
|
+
*/
|
|
108
|
+
export declare function formatBytes(bytes: number, decimals?: number): string;
|
|
109
|
+
/**
|
|
110
|
+
* Format a bitrate to a human-readable string.
|
|
111
|
+
*
|
|
112
|
+
* @param bitsPerSecond - Bitrate in bits per second
|
|
113
|
+
* @param decimals - Number of decimal places
|
|
114
|
+
* @returns Formatted bitrate string
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* formatBitrate(8000000) // "8 Mbps"
|
|
118
|
+
*/
|
|
119
|
+
export declare function formatBitrate(bitsPerSecond: number, decimals?: number): string;
|
|
120
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,GAAE,eAA0B,GAAG,MAAM,CAWzF;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,GAAE,eAAyB,GAAG,MAAM,CAWxF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,SAAS,GAAE,eAAyB,EACpC,SAAS,GAAE,eAAyB,GACnC,MAAM,CAYR;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,GAAE,IAAI,GAAG,MAAmB,GAAG,MAAM,CAqD/F;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5D,MAAM,CA2BR;AAMD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAGtF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,UAAU,UAAQ,GAAG,MAAM,CASrF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAU/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAUzE"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date, time, and number formatting utilities.
|
|
3
|
+
*
|
|
4
|
+
* Uses the native Intl API for locale-aware formatting.
|
|
5
|
+
* Works consistently across web and React Native environments.
|
|
6
|
+
*/
|
|
7
|
+
import i18n from 'i18next';
|
|
8
|
+
/**
|
|
9
|
+
* Format a date using the current locale.
|
|
10
|
+
*
|
|
11
|
+
* @param date - Date to format
|
|
12
|
+
* @param style - Format style ('short', 'medium', 'long', 'full')
|
|
13
|
+
* @returns Formatted date string
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* formatDate(new Date(), 'short') // "1/2/26" (en-US)
|
|
17
|
+
* formatDate(new Date(), 'long') // "January 2, 2026" (en-US)
|
|
18
|
+
*/
|
|
19
|
+
export function formatDate(date, style = 'medium') {
|
|
20
|
+
const locale = i18n.language || 'en';
|
|
21
|
+
const d = typeof date === 'number' ? new Date(date) : date;
|
|
22
|
+
if (isNaN(d.getTime())) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
return new Intl.DateTimeFormat(locale, {
|
|
26
|
+
dateStyle: style,
|
|
27
|
+
}).format(d);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format a time using the current locale.
|
|
31
|
+
*
|
|
32
|
+
* @param date - Date to format
|
|
33
|
+
* @param style - Format style ('short', 'medium', 'long', 'full')
|
|
34
|
+
* @returns Formatted time string
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* formatTime(new Date(), 'short') // "3:30 PM" (en-US)
|
|
38
|
+
*/
|
|
39
|
+
export function formatTime(date, style = 'short') {
|
|
40
|
+
const locale = i18n.language || 'en';
|
|
41
|
+
const d = typeof date === 'number' ? new Date(date) : date;
|
|
42
|
+
if (isNaN(d.getTime())) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
return new Intl.DateTimeFormat(locale, {
|
|
46
|
+
timeStyle: style,
|
|
47
|
+
}).format(d);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Format a date and time using the current locale.
|
|
51
|
+
*
|
|
52
|
+
* @param date - Date to format
|
|
53
|
+
* @param dateStyle - Date format style
|
|
54
|
+
* @param timeStyle - Time format style
|
|
55
|
+
* @returns Formatted datetime string
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* formatDateTime(new Date(), 'short', 'short') // "1/2/26, 3:30 PM" (en-US)
|
|
59
|
+
*/
|
|
60
|
+
export function formatDateTime(date, dateStyle = 'short', timeStyle = 'short') {
|
|
61
|
+
const locale = i18n.language || 'en';
|
|
62
|
+
const d = typeof date === 'number' ? new Date(date) : date;
|
|
63
|
+
if (isNaN(d.getTime())) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
return new Intl.DateTimeFormat(locale, {
|
|
67
|
+
dateStyle,
|
|
68
|
+
timeStyle,
|
|
69
|
+
}).format(d);
|
|
70
|
+
}
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// Relative Time Formatting
|
|
73
|
+
// ============================================================================
|
|
74
|
+
/**
|
|
75
|
+
* Format a relative time (e.g., "2 hours ago", "in 3 days").
|
|
76
|
+
*
|
|
77
|
+
* @param date - Date to compare to now
|
|
78
|
+
* @param now - Reference time (defaults to current time)
|
|
79
|
+
* @returns Formatted relative time string
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* formatRelativeTime(Date.now() - 3600000) // "1 hour ago"
|
|
83
|
+
* formatRelativeTime(Date.now() + 86400000) // "in 1 day"
|
|
84
|
+
*/
|
|
85
|
+
export function formatRelativeTime(date, now = Date.now()) {
|
|
86
|
+
const locale = i18n.language || 'en';
|
|
87
|
+
const d = typeof date === 'number' ? date : date.getTime();
|
|
88
|
+
const n = typeof now === 'number' ? now : now.getTime();
|
|
89
|
+
if (isNaN(d) || isNaN(n)) {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
const diff = d - n;
|
|
93
|
+
const absDiff = Math.abs(diff);
|
|
94
|
+
// Select appropriate unit
|
|
95
|
+
const seconds = absDiff / 1000;
|
|
96
|
+
const minutes = seconds / 60;
|
|
97
|
+
const hours = minutes / 60;
|
|
98
|
+
const days = hours / 24;
|
|
99
|
+
const weeks = days / 7;
|
|
100
|
+
const months = days / 30;
|
|
101
|
+
const years = days / 365;
|
|
102
|
+
let value;
|
|
103
|
+
let unit;
|
|
104
|
+
if (seconds < 60) {
|
|
105
|
+
value = Math.round(seconds);
|
|
106
|
+
unit = 'second';
|
|
107
|
+
}
|
|
108
|
+
else if (minutes < 60) {
|
|
109
|
+
value = Math.round(minutes);
|
|
110
|
+
unit = 'minute';
|
|
111
|
+
}
|
|
112
|
+
else if (hours < 24) {
|
|
113
|
+
value = Math.round(hours);
|
|
114
|
+
unit = 'hour';
|
|
115
|
+
}
|
|
116
|
+
else if (days < 7) {
|
|
117
|
+
value = Math.round(days);
|
|
118
|
+
unit = 'day';
|
|
119
|
+
}
|
|
120
|
+
else if (weeks < 4) {
|
|
121
|
+
value = Math.round(weeks);
|
|
122
|
+
unit = 'week';
|
|
123
|
+
}
|
|
124
|
+
else if (months < 12) {
|
|
125
|
+
value = Math.round(months);
|
|
126
|
+
unit = 'month';
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
value = Math.round(years);
|
|
130
|
+
unit = 'year';
|
|
131
|
+
}
|
|
132
|
+
// Adjust sign for past/future
|
|
133
|
+
const signedValue = diff < 0 ? -value : value;
|
|
134
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
135
|
+
numeric: 'auto',
|
|
136
|
+
}).format(signedValue, unit);
|
|
137
|
+
}
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Duration Formatting
|
|
140
|
+
// ============================================================================
|
|
141
|
+
/**
|
|
142
|
+
* Format a duration in milliseconds to a human-readable string.
|
|
143
|
+
*
|
|
144
|
+
* @param ms - Duration in milliseconds
|
|
145
|
+
* @param options - Formatting options
|
|
146
|
+
* @returns Formatted duration string
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* formatDuration(3661000) // "1h 1m 1s"
|
|
150
|
+
* formatDuration(3661000, { style: 'long' }) // "1 hour, 1 minute, 1 second"
|
|
151
|
+
*/
|
|
152
|
+
export function formatDuration(ms, options = {}) {
|
|
153
|
+
const { style = 'short', maxUnits = 3 } = options;
|
|
154
|
+
if (ms < 0)
|
|
155
|
+
ms = 0;
|
|
156
|
+
const seconds = Math.floor(ms / 1000) % 60;
|
|
157
|
+
const minutes = Math.floor(ms / 60000) % 60;
|
|
158
|
+
const hours = Math.floor(ms / 3600000) % 24;
|
|
159
|
+
const days = Math.floor(ms / 86400000);
|
|
160
|
+
const parts = [];
|
|
161
|
+
if (style === 'short') {
|
|
162
|
+
if (days > 0)
|
|
163
|
+
parts.push(`${days}d`);
|
|
164
|
+
if (hours > 0)
|
|
165
|
+
parts.push(`${hours}h`);
|
|
166
|
+
if (minutes > 0)
|
|
167
|
+
parts.push(`${minutes}m`);
|
|
168
|
+
if (seconds > 0 || parts.length === 0)
|
|
169
|
+
parts.push(`${seconds}s`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// Long style - use i18n translation keys with pluralization
|
|
173
|
+
if (days > 0)
|
|
174
|
+
parts.push(i18n.t('common:duration.day', { count: days }));
|
|
175
|
+
if (hours > 0)
|
|
176
|
+
parts.push(i18n.t('common:duration.hour', { count: hours }));
|
|
177
|
+
if (minutes > 0)
|
|
178
|
+
parts.push(i18n.t('common:duration.minute', { count: minutes }));
|
|
179
|
+
if (seconds > 0 || parts.length === 0)
|
|
180
|
+
parts.push(i18n.t('common:duration.second', { count: seconds }));
|
|
181
|
+
}
|
|
182
|
+
return parts.slice(0, maxUnits).join(style === 'short' ? ' ' : ', ');
|
|
183
|
+
}
|
|
184
|
+
// ============================================================================
|
|
185
|
+
// Number Formatting
|
|
186
|
+
// ============================================================================
|
|
187
|
+
/**
|
|
188
|
+
* Format a number using the current locale.
|
|
189
|
+
*
|
|
190
|
+
* @param value - Number to format
|
|
191
|
+
* @param options - Intl.NumberFormat options
|
|
192
|
+
* @returns Formatted number string
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* formatNumber(1234567.89) // "1,234,567.89" (en-US)
|
|
196
|
+
*/
|
|
197
|
+
export function formatNumber(value, options) {
|
|
198
|
+
const locale = i18n.language || 'en';
|
|
199
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Format a number as a percentage.
|
|
203
|
+
*
|
|
204
|
+
* @param value - Number to format (0-1 or 0-100 depending on usePercent)
|
|
205
|
+
* @param decimals - Number of decimal places
|
|
206
|
+
* @param usePercent - If true, value is already a percentage (0-100)
|
|
207
|
+
* @returns Formatted percentage string
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* formatPercent(0.75) // "75%"
|
|
211
|
+
* formatPercent(75, 1, true) // "75.0%"
|
|
212
|
+
*/
|
|
213
|
+
export function formatPercent(value, decimals = 0, usePercent = false) {
|
|
214
|
+
const locale = i18n.language || 'en';
|
|
215
|
+
const normalizedValue = usePercent ? value / 100 : value;
|
|
216
|
+
return new Intl.NumberFormat(locale, {
|
|
217
|
+
style: 'percent',
|
|
218
|
+
minimumFractionDigits: decimals,
|
|
219
|
+
maximumFractionDigits: decimals,
|
|
220
|
+
}).format(normalizedValue);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Format bytes to a human-readable size string.
|
|
224
|
+
*
|
|
225
|
+
* @param bytes - Number of bytes
|
|
226
|
+
* @param decimals - Number of decimal places
|
|
227
|
+
* @returns Formatted size string
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* formatBytes(1024) // "1 KB"
|
|
231
|
+
* formatBytes(1536, 1) // "1.5 KB"
|
|
232
|
+
*/
|
|
233
|
+
export function formatBytes(bytes, decimals = 1) {
|
|
234
|
+
if (bytes === 0)
|
|
235
|
+
return '0 B';
|
|
236
|
+
if (bytes < 0)
|
|
237
|
+
bytes = 0;
|
|
238
|
+
const k = 1024;
|
|
239
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
240
|
+
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1);
|
|
241
|
+
const value = bytes / Math.pow(k, i);
|
|
242
|
+
return `${formatNumber(value, { maximumFractionDigits: decimals })} ${sizes[i]}`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Format a bitrate to a human-readable string.
|
|
246
|
+
*
|
|
247
|
+
* @param bitsPerSecond - Bitrate in bits per second
|
|
248
|
+
* @param decimals - Number of decimal places
|
|
249
|
+
* @returns Formatted bitrate string
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* formatBitrate(8000000) // "8 Mbps"
|
|
253
|
+
*/
|
|
254
|
+
export function formatBitrate(bitsPerSecond, decimals = 1) {
|
|
255
|
+
if (bitsPerSecond === 0)
|
|
256
|
+
return '0 bps';
|
|
257
|
+
if (bitsPerSecond < 0)
|
|
258
|
+
bitsPerSecond = 0;
|
|
259
|
+
const k = 1000;
|
|
260
|
+
const sizes = ['bps', 'Kbps', 'Mbps', 'Gbps'];
|
|
261
|
+
const i = Math.min(Math.floor(Math.log(bitsPerSecond) / Math.log(k)), sizes.length - 1);
|
|
262
|
+
const value = bitsPerSecond / Math.pow(k, i);
|
|
263
|
+
return `${formatNumber(value, { maximumFractionDigits: decimals })} ${sizes[i]}`;
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAW3B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB,EAAE,QAAyB,QAAQ;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IACrC,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3D,IAAI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AC9C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxF,MAAM,KAAK,GAAG,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE7C,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tracearr/translations
|
|
3
|
+
*
|
|
4
|
+
* Shared i18n translations package for Tracearr web and mobile apps.
|
|
5
|
+
* Provides type-safe translation keys with IDE autocomplete.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { initI18n, useTranslation } from '@tracearr/translations';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize once at app startup
|
|
12
|
+
* await initI18n();
|
|
13
|
+
*
|
|
14
|
+
* // Use in components
|
|
15
|
+
* function MyComponent() {
|
|
16
|
+
* const { t } = useTranslation();
|
|
17
|
+
* return <button>{t('common.actions.save')}</button>;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // With namespaces
|
|
21
|
+
* function RulesComponent() {
|
|
22
|
+
* const { t } = useTranslation('pages');
|
|
23
|
+
* return <span>{t('rules.impossibleTravel')}</span>;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Language detection
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { detectLanguage, changeLanguage, languageNames } from '@tracearr/translations';
|
|
30
|
+
*
|
|
31
|
+
* // Detect user's preferred language
|
|
32
|
+
* const lang = await detectLanguage();
|
|
33
|
+
*
|
|
34
|
+
* // Change language
|
|
35
|
+
* await changeLanguage('es-ES');
|
|
36
|
+
*
|
|
37
|
+
* // Get available languages with display names
|
|
38
|
+
* Object.entries(languageNames).map(([code, name]) => ({ code, name }));
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export { i18n, initI18n, loadLocale, defaultI18nConfig, defaultNS, namespaces, resources, supportedLanguages, type SupportedLanguage, type Namespace, } from './config.js';
|
|
42
|
+
export { languageNames, getSupportedLanguages, isLanguageSupported, resolveLocale, detectLanguage, detectSystemLanguage, changeLanguage, getCurrentLanguage, getLanguageDisplayName, } from './language.js';
|
|
43
|
+
export type { AllResources, TranslationResources, CommonTranslations, NotificationsTranslations, SettingsTranslations, NavTranslations, PagesTranslations, MobileTranslations, NestedKeyOf, TranslationValue, CommonKey, NotificationsKey, SettingsKey, NavKey, PagesKey, MobileKey, } from './types.js';
|
|
44
|
+
export { formatDate, formatTime, formatDateTime, formatRelativeTime, formatDuration, formatNumber, formatPercent, formatBytes, formatBitrate, type DateFormatStyle, } from './formatting.js';
|
|
45
|
+
export { useTranslation, Trans, I18nextProvider } from 'react-i18next';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAElB,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tracearr/translations
|
|
3
|
+
*
|
|
4
|
+
* Shared i18n translations package for Tracearr web and mobile apps.
|
|
5
|
+
* Provides type-safe translation keys with IDE autocomplete.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { initI18n, useTranslation } from '@tracearr/translations';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize once at app startup
|
|
12
|
+
* await initI18n();
|
|
13
|
+
*
|
|
14
|
+
* // Use in components
|
|
15
|
+
* function MyComponent() {
|
|
16
|
+
* const { t } = useTranslation();
|
|
17
|
+
* return <button>{t('common.actions.save')}</button>;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // With namespaces
|
|
21
|
+
* function RulesComponent() {
|
|
22
|
+
* const { t } = useTranslation('pages');
|
|
23
|
+
* return <span>{t('rules.impossibleTravel')}</span>;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Language detection
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { detectLanguage, changeLanguage, languageNames } from '@tracearr/translations';
|
|
30
|
+
*
|
|
31
|
+
* // Detect user's preferred language
|
|
32
|
+
* const lang = await detectLanguage();
|
|
33
|
+
*
|
|
34
|
+
* // Change language
|
|
35
|
+
* await changeLanguage('es-ES');
|
|
36
|
+
*
|
|
37
|
+
* // Get available languages with display names
|
|
38
|
+
* Object.entries(languageNames).map(([code, name]) => ({ code, name }));
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
// Core i18n exports
|
|
42
|
+
export { i18n, initI18n, loadLocale, defaultI18nConfig, defaultNS, namespaces, resources, supportedLanguages, } from './config.js';
|
|
43
|
+
// Language detection and management
|
|
44
|
+
export { languageNames, getSupportedLanguages, isLanguageSupported, resolveLocale, detectLanguage, detectSystemLanguage, changeLanguage, getCurrentLanguage, getLanguageDisplayName, } from './language.js';
|
|
45
|
+
// Formatting utilities
|
|
46
|
+
export { formatDate, formatTime, formatDateTime, formatRelativeTime, formatDuration, formatNumber, formatPercent, formatBytes, formatBitrate, } from './formatting.js';
|
|
47
|
+
// Re-export react-i18next hooks for convenience
|
|
48
|
+
export { useTranslation, Trans, I18nextProvider } from 'react-i18next';
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,oBAAoB;AACpB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,SAAS,EACT,kBAAkB,GAGnB,MAAM,aAAa,CAAC;AAErB,oCAAoC;AACpC,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAuBvB,uBAAuB;AACvB,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,GAEd,MAAM,iBAAiB,CAAC;AAEzB,gDAAgD;AAChD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language detection and management utilities.
|
|
3
|
+
*
|
|
4
|
+
* Works in both web (browser) and mobile (React Native/Expo) environments.
|
|
5
|
+
* Language codes use full locale format (e.g., 'fr-FR', 'zh-CN') except for
|
|
6
|
+
* English which uses 'en' as the base/fallback language.
|
|
7
|
+
*/
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare function _registerLocaleLoader(fn: (lang: string) => Promise<void>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Supported languages with display names.
|
|
12
|
+
* Add new languages here when adding translations.
|
|
13
|
+
*/
|
|
14
|
+
export declare const languageNames: {
|
|
15
|
+
readonly en: "English";
|
|
16
|
+
readonly 'af-ZA': "Afrikaans";
|
|
17
|
+
readonly 'ar-SA': "العربية";
|
|
18
|
+
readonly 'ca-ES': "Català";
|
|
19
|
+
readonly 'cs-CZ': "Čeština";
|
|
20
|
+
readonly 'da-DK': "Dansk";
|
|
21
|
+
readonly 'de-DE': "Deutsch";
|
|
22
|
+
readonly 'el-GR': "Ελληνικά";
|
|
23
|
+
readonly 'es-ES': "Español";
|
|
24
|
+
readonly 'fi-FI': "Suomi";
|
|
25
|
+
readonly 'fr-FR': "Français";
|
|
26
|
+
readonly 'he-IL': "עברית";
|
|
27
|
+
readonly 'hu-HU': "Magyar";
|
|
28
|
+
readonly 'it-IT': "Italiano";
|
|
29
|
+
readonly 'ja-JP': "日本語";
|
|
30
|
+
readonly 'ko-KR': "한국어";
|
|
31
|
+
readonly 'nl-NL': "Nederlands";
|
|
32
|
+
readonly 'no-NO': "Norsk";
|
|
33
|
+
readonly 'pl-PL': "Polski";
|
|
34
|
+
readonly 'pt-BR': "Português (Brasil)";
|
|
35
|
+
readonly 'pt-PT': "Português (Portugal)";
|
|
36
|
+
readonly 'ro-RO': "Română";
|
|
37
|
+
readonly 'ru-RU': "Русский";
|
|
38
|
+
readonly 'sr-SP': "Српски";
|
|
39
|
+
readonly 'sv-SE': "Svenska";
|
|
40
|
+
readonly 'tr-TR': "Türkçe";
|
|
41
|
+
readonly 'uk-UA': "Українська";
|
|
42
|
+
readonly 'vi-VN': "Tiếng Việt";
|
|
43
|
+
readonly 'zh-CN': "中文 (简体)";
|
|
44
|
+
readonly 'zh-TW': "中文 (繁體)";
|
|
45
|
+
};
|
|
46
|
+
export type LanguageCode = keyof typeof languageNames;
|
|
47
|
+
/**
|
|
48
|
+
* Get the list of supported language codes.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getSupportedLanguages(): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Check if a language code is supported (exact match).
|
|
53
|
+
*/
|
|
54
|
+
export declare function isLanguageSupported(lang: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a language code to the best matching supported locale.
|
|
57
|
+
*
|
|
58
|
+
* Handles exact matches, legacy two-letter codes (e.g., 'fr' → 'fr-FR'),
|
|
59
|
+
* and browser locale strings (e.g., 'zh-Hant-TW' → 'zh-TW').
|
|
60
|
+
*
|
|
61
|
+
* Returns null if no match is found.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveLocale(lang: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Detect the user's preferred language.
|
|
66
|
+
*
|
|
67
|
+
* Priority order:
|
|
68
|
+
* 1. Stored preference (localStorage/AsyncStorage)
|
|
69
|
+
* 2. Browser/device language (checks all preferred languages)
|
|
70
|
+
* 3. Fallback to 'en'
|
|
71
|
+
*
|
|
72
|
+
* @param storage - Optional storage adapter for React Native (AsyncStorage)
|
|
73
|
+
*/
|
|
74
|
+
export declare function detectLanguage(storage?: {
|
|
75
|
+
getItem: (key: string) => Promise<string | null>;
|
|
76
|
+
}): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Detect the system/browser language.
|
|
79
|
+
* Checks all preferred languages in order (navigator.languages).
|
|
80
|
+
* Works in both web and React Native environments.
|
|
81
|
+
*/
|
|
82
|
+
export declare function detectSystemLanguage(): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Change the current language and persist the preference.
|
|
85
|
+
*
|
|
86
|
+
* @param lang - Locale code (e.g., 'en', 'fr-FR', 'zh-CN')
|
|
87
|
+
* @param storage - Optional storage adapter for React Native
|
|
88
|
+
* @throws Error if language code is invalid or unsupported
|
|
89
|
+
*/
|
|
90
|
+
export declare function changeLanguage(lang: string, storage?: {
|
|
91
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Get the current language.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getCurrentLanguage(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Get the display name for a language code.
|
|
99
|
+
*/
|
|
100
|
+
export declare function getLanguageDisplayName(lang: string): string;
|
|
101
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAE/E;AAKD;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,aAAa,CAAC;AAEtD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAA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