Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add data, fallbackLang & lang options as constructor arguments #40

Merged
merged 13 commits into from
Jan 26, 2024

Conversation

korvin89
Copy link
Contributor

@korvin89 korvin89 commented Jan 24, 2024

Add new arguments for I18N constructor:

  • data - keysets mapped data
  • fallbackLang - language used as fallback in case there is no translation in the target language
  • lang - target language for the i18n instance

Previous PR - #39

@korvin89 korvin89 mentioned this pull request Jan 24, 2024
@korvin89 korvin89 requested review from amje and ValeraS January 24, 2024 10:41
@korvin89 korvin89 changed the title feat: add data, defaultLang & lang options as constructor arguments feat: add data, fallbackLang & lang options as constructor arguments Jan 24, 2024
src/translation-helpers.ts Show resolved Hide resolved
src/translation-helpers.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@korvin89 korvin89 requested a review from dgaponov as a code owner January 24, 2024 12:00
src/index.ts Outdated Show resolved Hide resolved
dgaponov
dgaponov previously approved these changes Jan 25, 2024
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/translation-helpers.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
amje
amje previously approved these changes Jan 26, 2024
src/index.ts Outdated Show resolved Hide resolved
dgaponov
dgaponov previously approved these changes Jan 26, 2024
@korvin89 korvin89 dismissed stale reviews from dgaponov and amje via 3bf83ad January 26, 2024 15:39
@korvin89 korvin89 merged commit a26ee50 into main Jan 26, 2024
2 checks passed
@korvin89 korvin89 deleted the add-default-lang branch January 26, 2024 17:19
vladimirfilosof pushed a commit that referenced this pull request Mar 21, 2024
…40)

* feat: add data, defaultLang & lang options as constructor arguments

* refactor: rename defaultLang to fallbackLang

* refactor: throw an error in case of languages absence

* refactor: rework i18n method

* refactor: change ErrorCode naming

* fix: use object properties instead strings in mapErrorCodeToMessage switch cases

* fix: review fixes

* refactor: mark code property in mapErrorCodeToMessage as required

* fix: do not throw an error in case of NoLanguageData

* fix: remove fallbackLamg from getTranslationData method

* fix: remove none actual test

* fix: i18n method fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants