@firebase-oss/ui-translations 0.0.1

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/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var a={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",emailAlreadyInUse:"An account already exists with this email",weakPassword:"Password should be at least 8 characters",operationNotAllowed:"Email/password accounts are not enabled. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with Twitter",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method"}};var h={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/user-disabled":"userDisabled","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function o(e,i,n){let t=e.translations[i]?.[n];if(t)return t;if(e.fallback){let r=o(e.fallback,i,n);if(r)return r}return a[i][n]}function s(e,i,n){return {locale:e,translations:i,fallback:n}}var g=s("en-US",a);exports.ERROR_CODE_MAP=h;exports.enUs=g;exports.getTranslation=o;exports.registerLocale=s;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","translatedString","fallbackTranslation","registerLocale","translations","fallback","enUs"],"mappings":"aAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,YAAA,CAAc,0CAAA,CACd,aAAA,CAAe,oBAAA,CACf,YAAA,CAAc,oCAAA,CACd,YAAA,CAAc,gCAAA,CACd,qBAAsB,wEAAA,CACtB,eAAA,CAAiB,kDAAA,CACjB,iBAAA,CAAmB,2CAAA,CACnB,YAAA,CAAc,0CAAA,CACd,mBAAA,CAAqB,kEAAA,CACrB,kBAAA,CAAoB,6BAAA,CACpB,kBAAA,CAAoB,+BAAA,CACpB,aAAA,CAAe,4CAAA,CACf,WAAA,CAAa,oCACb,kBAAA,CAAoB,kDAAA,CACpB,qBAAA,CAAuB,mDAAA,CACvB,YAAA,CAAc,iCAAA,CACd,iBAAA,CAAmB,mDAAA,CACnB,sBAAA,CAAwB,8EAAA,CACxB,mBAAA,CAAqB,+DAAA,CACrB,qBAAA,CAAuB,wDAAA,CACvB,uBAAA,CAAyB,6CAAA,CACzB,aAAc,8BAAA,CACd,WAAA,CAAa,iDAAA,CACb,oCAAA,CACE,uFAAA,CACF,mBAAA,CAAqB,+BAAA,CACrB,wBAAA,CAA0B,0DAC5B,CAAA,CACA,QAAA,CAAU,CACR,sBAAA,CAAwB,wCAAA,CACxB,cAAA,CAAgB,gCAAA,CAChB,sBAAuB,0CAAA,CACvB,kBAAA,CAAoB,kDAAA,CACpB,SAAA,CAAW,IAAA,CACX,eAAA,C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BAAA,CAA6B,mBAAA,CAC7B,oBAAA,CAAsB,cAAA,CACtB,4BAAA,CAA8B,qBAAA,CAC9B,2BAAA,CAA6B,oBAAA,CAC7B,2BAAA,CAA6B,oBAAA,CAC7B,qBAAA,CAAuB,gBACvB,mBAAA,CAAqB,aAAA,CACrB,2BAAA,CAA6B,oBAAA,CAC7B,8BAAA,CAAgC,uBAAA,CAChC,oBAAA,CAAsB,cAAA,CACtB,2BAA4B,mBAAA,CAC5B,gCAAA,CAAkC,wBAAA,CAClC,4BAAA,CAA8B,qBAAA,CAC9B,8BAAA,CAAgC,uBAAA,CAChC,gCAAA,CAAkC,0BAClC,+CAAA,CAAiD,sCAAA,CACjD,4BAAA,CAA8B,qBAAA,CAC9B,mCAAA,CAAqC,0BACvC,EAIO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CAER,IAAMC,CAAAA,CADqBH,CAAAA,CAAO,aAAaC,CAAQ,CAAA,GACTC,CAAG,CAAA,CAEjD,GAAIC,CAAAA,CACF,OAAOA,CAAAA,CAIT,GAAIH,CAAAA,CAAO,QAAA,CAAU,CACnB,IAAMI,CAAAA,CAAsBL,CAAAA,CAAeC,CAAAA,CAAO,SAAUC,CAAAA,CAAUC,CAAG,CAAA,CAEzE,GAAIE,CAAAA,CACF,OAAOA,CAEX,CAIA,OAD+BP,CAAAA,CAAKI,CAAQ,CAAA,CACdC,CAAG,CACnC,CCjDO,SAASG,EACdL,CAAAA,CACAM,CAAAA,CACAC,CAAAA,CACkB,CAClB,OAAO,CACL,MAAA,CAAAP,CAAAA,CACA,aAAAM,CAAAA,CACA,QAAA,CAAAC,CACF,CACF,CAEO,IAAMC,CAAAA,CAAOH,CAAAA,CAAe,QAASR,CAAI","file":"index.cjs","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n// TODO: Should this be required or optional?\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n emailAlreadyInUse: \"An account already exists with this email\",\n weakPassword: \"Password should be at least 8 characters\",\n operationNotAllowed: \"Email/password accounts are not enabled. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with Twitter\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n if (translatedString) {\n return translatedString;\n }\n\n // Check fallback locale if it exists\n if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n return fallbackTranslation;\n }\n }\n\n // Fall back to English translations\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n return fallbackTranslationSet[key];\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\nexport const enUs = registerLocale(\"en-US\", enUS);\n\nexport type RegisteredLocale = {\n locale: Locale;\n translations: Translations;\n fallback?: RegisteredLocale;\n};\n"]}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ type TranslationCategory = keyof Required<Translations>;
17
+ type TranslationKey<T extends TranslationCategory> = keyof Required<Translations>[T];
18
+ type TranslationSet<T extends TranslationCategory> = Record<TranslationKey<T>, string>;
19
+ type ErrorKey = keyof Required<Translations>["errors"];
20
+ type MessageKey = keyof Required<Translations>["messages"];
21
+ type LabelKey = keyof Required<Translations>["labels"];
22
+ type PromptKey = keyof Required<Translations>["prompts"];
23
+ type TranslationsConfig = Partial<Record<string, Partial<Translations>>>;
24
+ type Translations = {
25
+ errors?: {
26
+ userNotFound?: string;
27
+ wrongPassword?: string;
28
+ invalidEmail?: string;
29
+ userDisabled?: string;
30
+ networkRequestFailed?: string;
31
+ tooManyRequests?: string;
32
+ emailAlreadyInUse?: string;
33
+ weakPassword?: string;
34
+ operationNotAllowed?: string;
35
+ invalidPhoneNumber?: string;
36
+ missingPhoneNumber?: string;
37
+ quotaExceeded?: string;
38
+ codeExpired?: string;
39
+ captchaCheckFailed?: string;
40
+ missingVerificationId?: string;
41
+ missingEmail?: string;
42
+ displayNameRequired?: string;
43
+ invalidActionCode?: string;
44
+ credentialAlreadyInUse?: string;
45
+ requiresRecentLogin?: string;
46
+ providerAlreadyLinked?: string;
47
+ invalidVerificationCode?: string;
48
+ unknownError?: string;
49
+ popupClosed?: string;
50
+ accountExistsWithDifferentCredential?: string;
51
+ secondFactorAlreadyInUse?: string;
52
+ };
53
+ messages?: {
54
+ passwordResetEmailSent?: string;
55
+ signInLinkSent?: string;
56
+ verificationCodeFirst?: string;
57
+ checkEmailForReset?: string;
58
+ dividerOr?: string;
59
+ termsAndPrivacy?: string;
60
+ };
61
+ labels?: {
62
+ emailAddress?: string;
63
+ password?: string;
64
+ displayName?: string;
65
+ forgotPassword?: string;
66
+ signUp?: string;
67
+ signIn?: string;
68
+ resetPassword?: string;
69
+ createAccount?: string;
70
+ backToSignIn?: string;
71
+ signInWithPhone?: string;
72
+ phoneNumber?: string;
73
+ verificationCode?: string;
74
+ sendCode?: string;
75
+ verifyCode?: string;
76
+ signInWithGoogle?: string;
77
+ signInWithFacebook?: string;
78
+ signInWithApple?: string;
79
+ signInWithTwitter?: string;
80
+ signInWithMicrosoft?: string;
81
+ signInWithGitHub?: string;
82
+ signInWithEmailLink?: string;
83
+ sendSignInLink?: string;
84
+ termsOfService?: string;
85
+ privacyPolicy?: string;
86
+ resendCode?: string;
87
+ sending?: string;
88
+ multiFactorEnrollment?: string;
89
+ mfaTotpVerification?: string;
90
+ mfaSmsVerification?: string;
91
+ generateQrCode?: string;
92
+ };
93
+ prompts?: {
94
+ noAccount?: string;
95
+ haveAccount?: string;
96
+ enterEmailToReset?: string;
97
+ signInToAccount?: string;
98
+ enterDetailsToCreate?: string;
99
+ enterPhoneNumber?: string;
100
+ enterVerificationCode?: string;
101
+ enterEmailForLink?: string;
102
+ mfaEnrollmentPrompt?: string;
103
+ };
104
+ };
105
+
106
+ /**
107
+ * Copyright 2025 Google LLC
108
+ *
109
+ * Licensed under the Apache License, Version 2.0 (the "License");
110
+ * you may not use this file except in compliance with the License.
111
+ * You may obtain a copy of the License at
112
+ *
113
+ * http://www.apache.org/licenses/LICENSE-2.0
114
+ *
115
+ * Unless required by applicable law or agreed to in writing, software
116
+ * distributed under the License is distributed on an "AS IS" BASIS,
117
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118
+ * See the License for the specific language governing permissions and
119
+ * limitations under the License.
120
+ */
121
+
122
+ declare const ERROR_CODE_MAP: {
123
+ "auth/user-not-found": "userNotFound";
124
+ "auth/wrong-password": "wrongPassword";
125
+ "auth/invalid-email": "invalidEmail";
126
+ "auth/user-disabled": "userDisabled";
127
+ "auth/network-request-failed": "networkRequestFailed";
128
+ "auth/too-many-requests": "tooManyRequests";
129
+ "auth/email-already-in-use": "emailAlreadyInUse";
130
+ "auth/weak-password": "weakPassword";
131
+ "auth/operation-not-allowed": "operationNotAllowed";
132
+ "auth/invalid-phone-number": "invalidPhoneNumber";
133
+ "auth/missing-phone-number": "missingPhoneNumber";
134
+ "auth/quota-exceeded": "quotaExceeded";
135
+ "auth/code-expired": "codeExpired";
136
+ "auth/captcha-check-failed": "captchaCheckFailed";
137
+ "auth/missing-verification-id": "missingVerificationId";
138
+ "auth/missing-email": "missingEmail";
139
+ "auth/invalid-action-code": "invalidActionCode";
140
+ "auth/credential-already-in-use": "credentialAlreadyInUse";
141
+ "auth/requires-recent-login": "requiresRecentLogin";
142
+ "auth/provider-already-linked": "providerAlreadyLinked";
143
+ "auth/invalid-verification-code": "invalidVerificationCode";
144
+ "auth/account-exists-with-different-credential": "accountExistsWithDifferentCredential";
145
+ "auth/display-name-required": "displayNameRequired";
146
+ "auth/second-factor-already-in-use": "secondFactorAlreadyInUse";
147
+ };
148
+ type ErrorCode = keyof typeof ERROR_CODE_MAP;
149
+ declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>): string;
150
+
151
+ /**
152
+ * Copyright 2025 Google LLC
153
+ *
154
+ * Licensed under the Apache License, Version 2.0 (the "License");
155
+ * you may not use this file except in compliance with the License.
156
+ * You may obtain a copy of the License at
157
+ *
158
+ * http://www.apache.org/licenses/LICENSE-2.0
159
+ *
160
+ * Unless required by applicable law or agreed to in writing, software
161
+ * distributed under the License is distributed on an "AS IS" BASIS,
162
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163
+ * See the License for the specific language governing permissions and
164
+ * limitations under the License.
165
+ */
166
+
167
+ type Locale = "en-US" | `${string}-${string}` | string;
168
+ declare function registerLocale(locale: Locale, translations: Translations, fallback?: RegisteredLocale): RegisteredLocale;
169
+ declare const enUs: RegisteredLocale;
170
+ type RegisteredLocale = {
171
+ locale: Locale;
172
+ translations: Translations;
173
+ fallback?: RegisteredLocale;
174
+ };
175
+
176
+ export { ERROR_CODE_MAP, type ErrorCode, type ErrorKey, type LabelKey, type Locale, type MessageKey, type PromptKey, type RegisteredLocale, type TranslationCategory, type TranslationKey, type TranslationSet, type Translations, type TranslationsConfig, enUs, getTranslation, registerLocale };
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ type TranslationCategory = keyof Required<Translations>;
17
+ type TranslationKey<T extends TranslationCategory> = keyof Required<Translations>[T];
18
+ type TranslationSet<T extends TranslationCategory> = Record<TranslationKey<T>, string>;
19
+ type ErrorKey = keyof Required<Translations>["errors"];
20
+ type MessageKey = keyof Required<Translations>["messages"];
21
+ type LabelKey = keyof Required<Translations>["labels"];
22
+ type PromptKey = keyof Required<Translations>["prompts"];
23
+ type TranslationsConfig = Partial<Record<string, Partial<Translations>>>;
24
+ type Translations = {
25
+ errors?: {
26
+ userNotFound?: string;
27
+ wrongPassword?: string;
28
+ invalidEmail?: string;
29
+ userDisabled?: string;
30
+ networkRequestFailed?: string;
31
+ tooManyRequests?: string;
32
+ emailAlreadyInUse?: string;
33
+ weakPassword?: string;
34
+ operationNotAllowed?: string;
35
+ invalidPhoneNumber?: string;
36
+ missingPhoneNumber?: string;
37
+ quotaExceeded?: string;
38
+ codeExpired?: string;
39
+ captchaCheckFailed?: string;
40
+ missingVerificationId?: string;
41
+ missingEmail?: string;
42
+ displayNameRequired?: string;
43
+ invalidActionCode?: string;
44
+ credentialAlreadyInUse?: string;
45
+ requiresRecentLogin?: string;
46
+ providerAlreadyLinked?: string;
47
+ invalidVerificationCode?: string;
48
+ unknownError?: string;
49
+ popupClosed?: string;
50
+ accountExistsWithDifferentCredential?: string;
51
+ secondFactorAlreadyInUse?: string;
52
+ };
53
+ messages?: {
54
+ passwordResetEmailSent?: string;
55
+ signInLinkSent?: string;
56
+ verificationCodeFirst?: string;
57
+ checkEmailForReset?: string;
58
+ dividerOr?: string;
59
+ termsAndPrivacy?: string;
60
+ };
61
+ labels?: {
62
+ emailAddress?: string;
63
+ password?: string;
64
+ displayName?: string;
65
+ forgotPassword?: string;
66
+ signUp?: string;
67
+ signIn?: string;
68
+ resetPassword?: string;
69
+ createAccount?: string;
70
+ backToSignIn?: string;
71
+ signInWithPhone?: string;
72
+ phoneNumber?: string;
73
+ verificationCode?: string;
74
+ sendCode?: string;
75
+ verifyCode?: string;
76
+ signInWithGoogle?: string;
77
+ signInWithFacebook?: string;
78
+ signInWithApple?: string;
79
+ signInWithTwitter?: string;
80
+ signInWithMicrosoft?: string;
81
+ signInWithGitHub?: string;
82
+ signInWithEmailLink?: string;
83
+ sendSignInLink?: string;
84
+ termsOfService?: string;
85
+ privacyPolicy?: string;
86
+ resendCode?: string;
87
+ sending?: string;
88
+ multiFactorEnrollment?: string;
89
+ mfaTotpVerification?: string;
90
+ mfaSmsVerification?: string;
91
+ generateQrCode?: string;
92
+ };
93
+ prompts?: {
94
+ noAccount?: string;
95
+ haveAccount?: string;
96
+ enterEmailToReset?: string;
97
+ signInToAccount?: string;
98
+ enterDetailsToCreate?: string;
99
+ enterPhoneNumber?: string;
100
+ enterVerificationCode?: string;
101
+ enterEmailForLink?: string;
102
+ mfaEnrollmentPrompt?: string;
103
+ };
104
+ };
105
+
106
+ /**
107
+ * Copyright 2025 Google LLC
108
+ *
109
+ * Licensed under the Apache License, Version 2.0 (the "License");
110
+ * you may not use this file except in compliance with the License.
111
+ * You may obtain a copy of the License at
112
+ *
113
+ * http://www.apache.org/licenses/LICENSE-2.0
114
+ *
115
+ * Unless required by applicable law or agreed to in writing, software
116
+ * distributed under the License is distributed on an "AS IS" BASIS,
117
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118
+ * See the License for the specific language governing permissions and
119
+ * limitations under the License.
120
+ */
121
+
122
+ declare const ERROR_CODE_MAP: {
123
+ "auth/user-not-found": "userNotFound";
124
+ "auth/wrong-password": "wrongPassword";
125
+ "auth/invalid-email": "invalidEmail";
126
+ "auth/user-disabled": "userDisabled";
127
+ "auth/network-request-failed": "networkRequestFailed";
128
+ "auth/too-many-requests": "tooManyRequests";
129
+ "auth/email-already-in-use": "emailAlreadyInUse";
130
+ "auth/weak-password": "weakPassword";
131
+ "auth/operation-not-allowed": "operationNotAllowed";
132
+ "auth/invalid-phone-number": "invalidPhoneNumber";
133
+ "auth/missing-phone-number": "missingPhoneNumber";
134
+ "auth/quota-exceeded": "quotaExceeded";
135
+ "auth/code-expired": "codeExpired";
136
+ "auth/captcha-check-failed": "captchaCheckFailed";
137
+ "auth/missing-verification-id": "missingVerificationId";
138
+ "auth/missing-email": "missingEmail";
139
+ "auth/invalid-action-code": "invalidActionCode";
140
+ "auth/credential-already-in-use": "credentialAlreadyInUse";
141
+ "auth/requires-recent-login": "requiresRecentLogin";
142
+ "auth/provider-already-linked": "providerAlreadyLinked";
143
+ "auth/invalid-verification-code": "invalidVerificationCode";
144
+ "auth/account-exists-with-different-credential": "accountExistsWithDifferentCredential";
145
+ "auth/display-name-required": "displayNameRequired";
146
+ "auth/second-factor-already-in-use": "secondFactorAlreadyInUse";
147
+ };
148
+ type ErrorCode = keyof typeof ERROR_CODE_MAP;
149
+ declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>): string;
150
+
151
+ /**
152
+ * Copyright 2025 Google LLC
153
+ *
154
+ * Licensed under the Apache License, Version 2.0 (the "License");
155
+ * you may not use this file except in compliance with the License.
156
+ * You may obtain a copy of the License at
157
+ *
158
+ * http://www.apache.org/licenses/LICENSE-2.0
159
+ *
160
+ * Unless required by applicable law or agreed to in writing, software
161
+ * distributed under the License is distributed on an "AS IS" BASIS,
162
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163
+ * See the License for the specific language governing permissions and
164
+ * limitations under the License.
165
+ */
166
+
167
+ type Locale = "en-US" | `${string}-${string}` | string;
168
+ declare function registerLocale(locale: Locale, translations: Translations, fallback?: RegisteredLocale): RegisteredLocale;
169
+ declare const enUs: RegisteredLocale;
170
+ type RegisteredLocale = {
171
+ locale: Locale;
172
+ translations: Translations;
173
+ fallback?: RegisteredLocale;
174
+ };
175
+
176
+ export { ERROR_CODE_MAP, type ErrorCode, type ErrorKey, type LabelKey, type Locale, type MessageKey, type PromptKey, type RegisteredLocale, type TranslationCategory, type TranslationKey, type TranslationSet, type Translations, type TranslationsConfig, enUs, getTranslation, registerLocale };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ var a={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",emailAlreadyInUse:"An account already exists with this email",weakPassword:"Password should be at least 8 characters",operationNotAllowed:"Email/password accounts are not enabled. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with Twitter",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method"}};var h={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/user-disabled":"userDisabled","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function o(e,i,n){let t=e.translations[i]?.[n];if(t)return t;if(e.fallback){let r=o(e.fallback,i,n);if(r)return r}return a[i][n]}function s(e,i,n){return {locale:e,translations:i,fallback:n}}var g=s("en-US",a);export{h as ERROR_CODE_MAP,g as enUs,o as getTranslation,s as registerLocale};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","translatedString","fallbackTranslation","registerLocale","translations","fallback","enUs"],"mappings":"AAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,YAAA,CAAc,0CAAA,CACd,aAAA,CAAe,oBAAA,CACf,YAAA,CAAc,oCAAA,CACd,YAAA,CAAc,gCAAA,CACd,qBAAsB,wEAAA,CACtB,eAAA,CAAiB,kDAAA,CACjB,iBAAA,CAAmB,2CAAA,CACnB,YAAA,CAAc,0CAAA,CACd,mBAAA,CAAqB,kEAAA,CACrB,kBAAA,CAAoB,6BAAA,CACpB,kBAAA,CAAoB,+BAAA,CACpB,aAAA,CAAe,4CAAA,CACf,WAAA,CAAa,oCACb,kBAAA,CAAoB,kDAAA,CACpB,qBAAA,CAAuB,mDAAA,CACvB,YAAA,CAAc,iCAAA,CACd,iBAAA,CAAmB,mDAAA,CACnB,sBAAA,CAAwB,8EAAA,CACxB,mBAAA,CAAqB,+DAAA,CACrB,qBAAA,CAAuB,wDAAA,CACvB,uBAAA,CAAyB,6CAAA,CACzB,aAAc,8BAAA,CACd,WAAA,CAAa,iDAAA,CACb,oCAAA,CACE,uFAAA,CACF,mBAAA,CAAqB,+BAAA,CACrB,wBAAA,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CAAOH,CAAAA,CAAe,QAASR,CAAI","file":"index.js","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n// TODO: Should this be required or optional?\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n emailAlreadyInUse: \"An account already exists with this email\",\n weakPassword: \"Password should be at least 8 characters\",\n operationNotAllowed: \"Email/password accounts are not enabled. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with Twitter\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n if (translatedString) {\n return translatedString;\n }\n\n // Check fallback locale if it exists\n if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n return fallbackTranslation;\n }\n }\n\n // Fall back to English translations\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n return fallbackTranslationSet[key];\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\nexport const enUs = registerLocale(\"en-US\", enUS);\n\nexport type RegisteredLocale = {\n locale: Locale;\n translations: Translations;\n fallback?: RegisteredLocale;\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@firebase-oss/ui-translations",
3
+ "version": "0.0.1",
4
+ "description": "Translations for Firebase UI",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "prepare": "tsup",
21
+ "build": "tsup",
22
+ "build:local": "pnpm run build && pnpm pack",
23
+ "dev": "tsup --watch",
24
+ "lint": "tsc --noEmit",
25
+ "format": "prettier --write \"src/**/*.ts\"",
26
+ "clean": "rimraf dist",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest",
29
+ "publish:tags": "sh -c 'TAG=\"${npm_package_name}@${npm_package_version}\"; git tag --list \"$TAG\" | grep . || git tag \"$TAG\"; git push origin \"$TAG\"'",
30
+ "release": "npm run build && pnpm pack --pack-destination ../../releases/"
31
+ },
32
+ "devDependencies": {
33
+ "rimraf": "catalog:",
34
+ "vitest": "catalog:",
35
+ "tsup": "catalog:",
36
+ "typescript": "catalog:"
37
+ }
38
+ }