Skip to content

Commit

Permalink
Refactoring i18n package to accomodate new UI modules in cleaner and …
Browse files Browse the repository at this point in the history
…modular way
  • Loading branch information
pramod prajapati committed Nov 22, 2021
1 parent c3a5e17 commit d0b8ed6
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 64 deletions.
File renamed without changes.
57 changes: 57 additions & 0 deletions packages/ui/src/i18n/dictionaries/authenticator/defaultTexts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export const defaultTexts = {
BACK_SIGN_IN: 'Back to Sign In',
BIRTHDATE: 'Birthdate',
CHANGE_PASSWORD: 'Change Password',
CHANGING_PASSWORD: 'Changing',
CODE: 'Code',
CONFIRM_PASSWORD: 'Confirm Password',
CONFIRM_RESET_PASSWORD_HEADING: 'Reset your Password',
CONFIRM_SIGNUP_HEADING: 'Confirm Sign Up',
CONFIRM_SMS: 'Confirm SMS Code',
CONFIRM_TOTP: 'Confirm TOTP Code',
CONFIRM: 'Confirm',
CONFIRMATION_CODE: 'Confirmation Code',
CONFIRMING: 'Confirming',
CREATE_ACCOUNT: 'Create Account',
CREATING_ACCOUNT: 'Creating Account',
EMAIL_ADDRESS: 'Email',
ENTER_CODE: 'Enter your code',
ENTER_USERNAME: 'Enter your username',
FAMILY_NAME: 'Family Name',
GIVEN_NAME: 'Given Name',
FORGOT_YOUR_PASSWORD: 'Forgot your password? ',
HIDE_PASSWORD: 'Hide password',
LOADING: 'Loading',
LOGIN_NAME: 'Username',
MIDDLE_NAME: 'Middle Name',
NAME: 'Name',
NICKNAME: 'Nickname',
NEW_PASSWORD: 'New password',
PASSWORD: 'Password',
PHONE_NUMBER: 'Phone Number',
PREFERRED_USERNAME: 'Preferred Username',
PROFILE: 'Profile',
RESEND_CODE: 'Resend Code',
RESET_PASSWORD_HEADING: 'Reset your password',
RESET_PASSWORD: 'Send Code',
SEND_CODE: 'Send code',
SENDING: 'Sending',
SETUP_TOTP: 'Setup TOTP',
SHOW_PASSWORD: 'Show password',
SIGN_IN_BUTTON: 'Sign in',
SIGN_IN_TAB: 'Sign In',
SIGN_IN_WITH_AMAZON: 'Sign In with Amazon',
SIGN_IN_WITH_APPLE: 'Sign In with Apple',
SIGN_IN_WITH_FACEBOOK: 'Sign In with Facebook',
SIGN_IN_WITH_GOOGLE: 'Sign In with Google',
SIGN_IN: 'Sign in to your account',
SIGN_UP_BUTTON: 'Create a new account',
SIGNING_IN_BUTTON: 'Signing in',
SKIP: 'Skip',
SUBMIT: 'Submit',
SUBMITTING: 'Submitting',
VERIFY_CONTACT: 'Verify Contact',
VERIFY_HEADING: 'Account recovery requires verified contact information',
VERIFY: 'Verify',
WEBSITE: 'Website',
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/ui/src/i18n/dictionaries/authenticator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// translation dictionaries
export { deDict } from './de';
export { enDict } from './en';
export { esDict } from './es';
export { frDict } from './fr';
export { itDict } from './it';
export { jaDict } from './ja';
export { zhDict } from './zh';

// default text phrases
export { defaultTexts } from './defaultTexts';
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 15 additions & 7 deletions packages/ui/src/i18n/dictionaries/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
export { deDict } from './de';
export { enDict } from './en';
export { esDict } from './es';
export { frDict } from './fr';
export { itDict } from './it';
export { jaDict } from './ja';
export { zhDict } from './zh';
import * as authenticatorDict from './authenticator';

//merge all the new module translations in respective locale constants
export const deDict = { ...authenticatorDict.deDict };
export const enDict = { ...authenticatorDict.enDict };
export const esDict = { ...authenticatorDict.esDict };
export const frDict = { ...authenticatorDict.frDict };
export const itDict = { ...authenticatorDict.itDict };
export const jaDict = { ...authenticatorDict.jaDict };
export const zhDict = { ...authenticatorDict.zhDict };

export const defaultTexts = {
...authenticatorDict.defaultTexts,
// new module related default texts goes here
};
59 changes: 2 additions & 57 deletions packages/ui/src/i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
itDict,
jaDict,
zhDict,
defaultTexts,
} from './dictionaries';

/**
Expand All @@ -33,63 +34,7 @@ import {
* });
* ```
*/
export const DefaultTexts = {
BACK_SIGN_IN: 'Back to Sign In',
BIRTHDATE: 'Birthdate',
CHANGE_PASSWORD: 'Change Password',
CHANGING_PASSWORD: 'Changing',
CODE: 'Code',
CONFIRM_PASSWORD: 'Confirm Password',
CONFIRM_RESET_PASSWORD_HEADING: 'Reset your Password',
CONFIRM_SIGNUP_HEADING: 'Confirm Sign Up',
CONFIRM_SMS: 'Confirm SMS Code',
CONFIRM_TOTP: 'Confirm TOTP Code',
CONFIRM: 'Confirm',
CONFIRMATION_CODE: 'Confirmation Code',
CONFIRMING: 'Confirming',
CREATE_ACCOUNT: 'Create Account',
CREATING_ACCOUNT: 'Creating Account',
EMAIL_ADDRESS: 'Email',
ENTER_CODE: 'Enter your code',
ENTER_USERNAME: 'Enter your username',
FAMILY_NAME: 'Family Name',
GIVEN_NAME: 'Given Name',
FORGOT_YOUR_PASSWORD: 'Forgot your password? ',
HIDE_PASSWORD: 'Hide password',
LOADING: 'Loading',
LOGIN_NAME: 'Username',
MIDDLE_NAME: 'Middle Name',
NAME: 'Name',
NICKNAME: 'Nickname',
NEW_PASSWORD: 'New password',
PASSWORD: 'Password',
PHONE_NUMBER: 'Phone Number',
PREFERRED_USERNAME: 'Preferred Username',
PROFILE: 'Profile',
RESEND_CODE: 'Resend Code',
RESET_PASSWORD_HEADING: 'Reset your password',
RESET_PASSWORD: 'Send Code',
SEND_CODE: 'Send code',
SENDING: 'Sending',
SETUP_TOTP: 'Setup TOTP',
SHOW_PASSWORD: 'Show password',
SIGN_IN_BUTTON: 'Sign in',
SIGN_IN_TAB: 'Sign In',
SIGN_IN_WITH_AMAZON: 'Sign In with Amazon',
SIGN_IN_WITH_APPLE: 'Sign In with Apple',
SIGN_IN_WITH_FACEBOOK: 'Sign In with Facebook',
SIGN_IN_WITH_GOOGLE: 'Sign In with Google',
SIGN_IN: 'Sign in to your account',
SIGN_UP_BUTTON: 'Create a new account',
SIGNING_IN_BUTTON: 'Signing in',
SKIP: 'Skip',
SUBMIT: 'Submit',
SUBMITTING: 'Submitting',
VERIFY_CONTACT: 'Verify Contact',
VERIFY_HEADING: 'Account recovery requires verified contact information',
VERIFY: 'Verify',
WEBSITE: 'Website',
} as const;
export const DefaultTexts = { ...defaultTexts } as const;

// type Phrase = "Back to Sign In" | "Change Password" | ...
export type Phrase = typeof DefaultTexts[keyof typeof DefaultTexts];
Expand Down

0 comments on commit d0b8ed6

Please sign in to comment.