Skip to content

Commit

Permalink
ECO-1704: SDK Localization (#241)
Browse files Browse the repository at this point in the history
## Motivation / Description
This PR introduces localization for the SDK

## Changes introduced
* Introduced the Translator class and the `<Localized>` component.
* Added initial translations for en, es, it
* Converted all the hardcoded labels to use Translator or `<Localized>`

# Supported Languages
* ar - Arabic
* ca - Catalan
* cs - Czech
* da - Danish
* de - German
* el - Greek
* en - English
* es - Spanish
* fi - Finnish
* fr - French
* he - Hebrew
* hi - Hindi
* hr - Croatian
* hu - Hungarian
* id - Indonesian
* it - Italian
* ja - Japanese
* ko - Korean
* ms - Malay
* nl - Dutch
* no - Norwegian
* pl - Polish
* pt - Portuguese
* ro - Romanian
* ru - Russian
* sk - Slovak
* sv - Swedish
* th - Thai
* tr - Turkish
* uk - Ukranian
* vi - Vietnamese
* zh_Hans - Chinese
* zh_Hant - Chinese

---------

Co-authored-by: Guido Torres <[email protected]>
Co-authored-by: Ed Shelley <[email protected]>
Co-authored-by: Víctor Ferrer García <[email protected]>
Co-authored-by: Toni Rico <[email protected]>
Co-authored-by: Guido Torres <[email protected]>
  • Loading branch information
6 people authored Dec 5, 2024
1 parent f3ba284 commit 79b425c
Show file tree
Hide file tree
Showing 94 changed files with 8,597 additions and 1,769 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
],
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
Expand Down
56 changes: 55 additions & 1 deletion api-report/purchases-js.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -3884,6 +3884,33 @@
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@revenuecat/purchases-js!PurchaseParams#defaultLocale:member",
"docComment": "/**\n * The default locale to use if the selectedLocale is not available. Defaults to english.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "defaultLocale?: "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": true,
"releaseTag": "Public",
"name": "defaultLocale",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@revenuecat/purchases-js!PurchaseParams#htmlTarget:member",
Expand Down Expand Up @@ -3971,6 +3998,33 @@
"startIndex": 1,
"endIndex": 2
}
},
{
"kind": "PropertySignature",
"canonicalReference": "@revenuecat/purchases-js!PurchaseParams#selectedLocale:member",
"docComment": "/**\n * The locale to use for the purchase flow. If not specified, the device's locale will be used.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "selectedLocale?: "
},
{
"kind": "Content",
"text": "string"
},
{
"kind": "Content",
"text": ";"
}
],
"isReadonly": false,
"isOptional": true,
"releaseTag": "Public",
"name": "selectedLocale",
"propertyTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
}
],
"extendsTokenRanges": []
Expand Down Expand Up @@ -4247,7 +4301,7 @@
{
"kind": "Method",
"canonicalReference": "@revenuecat/purchases-js!Purchases.generateRevenueCatAnonymousAppUserId:member(1)",
"docComment": "/**\n * Generates an anonymous app user ID that follows RevenueCat's format. This can be used when you don't have a user identifier system in place. The generated ID will be in the format: $RCAnonymousID:<UUID without dashes>\n *\n * @returns A new anonymous app user ID string\n *\n * @public\n */\n",
"docComment": "/**\n * Generates an anonymous app user ID that follows RevenueCat's format. This can be used when you don't have a user identifier system in place. The generated ID will be in the format: $RCAnonymousID:\\<UUID without dashes\\> Example: $RCAnonymousID:123e4567e89b12d3a456426614174000\n *\n * @returns A new anonymous app user ID string\n *\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
Expand Down
2 changes: 2 additions & 0 deletions api-report/purchases-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ export interface PurchaseOption {
// @public
export interface PurchaseParams {
customerEmail?: string;
defaultLocale?: string;
htmlTarget?: HTMLElement;
purchaseOption?: PurchaseOption | null;
rcPackage: Package;
selectedLocale?: string;
}

// @public
Expand Down
21 changes: 21 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js, ts, svelte}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
},
},
];
19 changes: 0 additions & 19 deletions examples/rcbilling-demo/.eslintrc.cjs

This file was deleted.

21 changes: 21 additions & 0 deletions examples/rcbilling-demo/.eslintrc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js, ts, svelte}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
},
},
];
Loading

0 comments on commit 79b425c

Please sign in to comment.