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

Appwrite console internationalization : Typesafe-i18n #459

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b8a2be4
getting started with i18n
goswamianshuman May 22, 2023
f9145de
made suggested changes
goswamianshuman May 23, 2023
5d33e68
updated library to i18next
goswamianshuman May 23, 2023
6da4889
removed unwanted packages
goswamianshuman May 23, 2023
78eda23
initiate typesafe-i18n
goswamianshuman Jun 3, 2023
6910551
typesafe-i18n attempt
goswamianshuman Jun 4, 2023
4be78df
updated package.json
goswamianshuman Jun 4, 2023
70f993c
finializing code for review
goswamianshuman Jun 4, 2023
14c3b54
updated languageSelector
goswamianshuman Jun 4, 2023
49c05b5
channged texts from js objects to json
goswamianshuman Jun 6, 2023
b019a14
renwed i18n and selector
goswamianshuman Jun 9, 2023
a672c2b
updated alias
goswamianshuman Jun 9, 2023
47004fb
update language selector
goswamianshuman Jun 10, 2023
6ac1324
updates in typesafe-i18n
goswamianshuman Jun 12, 2023
64866de
added typesafe to build
goswamianshuman Jun 14, 2023
61d4e3e
typesafe with build
goswamianshuman Jun 14, 2023
bc4e690
processed i18n files from src/lib/i18n to src/i18n
goswamianshuman Jun 14, 2023
713eebb
testing new json key structure
goswamianshuman Jun 22, 2023
2d51bcd
updated previous data (english only)
goswamianshuman Jun 26, 2023
3b94c69
updated other lang files
goswamianshuman Jun 28, 2023
e5340db
updated console/accounts (eng only)
goswamianshuman Jul 10, 2023
3493d6b
updated console/onboarding (eng only)
goswamianshuman Jul 10, 2023
2f78338
basic changes
goswamianshuman Jul 10, 2023
bec72ed
updated console/organization (eng only)
goswamianshuman Jul 12, 2023
4ad2d1f
basic updates
goswamianshuman Jul 12, 2023
d22bdd8
updating previous structure (eng only)
goswamianshuman Jul 15, 2023
2d311d2
modified data in console/project/auth (eng lang only)
goswamianshuman Jul 17, 2023
6280ba1
modified console/project/auth
goswamianshuman Jul 19, 2023
fd4872f
modified console/project/auth (eng lang only)
goswamianshuman Jul 20, 2023
f315071
modification in console/project/auth completed and databases started
goswamianshuman Jul 22, 2023
bc0b906
completed modification of data in console/project/databases
goswamianshuman Jul 27, 2023
9a82260
modification completed in settings
Jul 29, 2023
cbe3410
completed modification in console / overview
Jul 30, 2023
3bfa2c2
completed modification in console/functions
Jul 30, 2023
e0e4d20
modification complete in console/storage
Jul 30, 2023
b31f147
minor updates
Jul 31, 2023
20f2d13
updated en.json and de.json
Jul 31, 2023
f7619cc
modified english and italian json
Aug 1, 2023
44232bb
usage updated
Aug 1, 2023
0327063
updated collection
Aug 1, 2023
567743f
updated sidebar
Aug 1, 2023
b4286cf
modified components, layout and mock's data
Aug 4, 2023
94f561d
modified platform and its elements
Aug 6, 2023
2b665a4
minor updates
Aug 6, 2023
60f4683
updated keys dates and mainOauth
Aug 6, 2023
756882e
updated notifications
Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules
node_modules/
dist/
.vercel
.github
goswamianshuman marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .typesafe-i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"adapter": "svelte",
"$schema": "https://unpkg.com/[email protected]/schema/typesafe-i18n.json",
"outputPath": "./src/lib/i18n/"
}
102 changes: 101 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"node": ">=16"
},
"scripts": {
"dev": "vite dev",
"dev": "npm-run-all --parallel vite typesafe-i18n",
goswamianshuman marked this conversation as resolved.
Show resolved Hide resolved
"vite": "vite dev",
"build": "node build.js",
"preview": "vite preview",
"sync": "svelte-kit sync",
Expand All @@ -15,7 +16,8 @@
"test": "vitest run",
"test:ui": "vitest --ui",
"test:watch": "vitest watch",
"e2e": "playwright test tests/e2e"
"e2e": "playwright test tests/e2e",
"typesafe-i18n": "typesafe-i18n"
},
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
Expand All @@ -28,9 +30,11 @@
"dotenv": "^16.0.3",
"echarts": "^5.4.1",
"logrocket": "^3.0.1",
"npm-run-all": "^4.1.5",
"pretty-bytes": "^6.1.0",
"prismjs": "^1.29.0",
"tippy.js": "^6.3.7",
"typesafe-i18n": "^5.24.3",
"web-vitals": "^3.1.1"
},
"devDependencies": {
Expand Down
29 changes: 29 additions & 0 deletions src/lib/components/LanguageSelector.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import { locale, setLocale } from '$lib/i18n/i18n-svelte';
import type { Locales } from '$lib/i18n/i18n-types';
import { locales } from '$lib/i18n/i18n-util';
import { loadLocaleAsync } from '$lib/i18n/i18n-util.async';

const lang = [
{ value: 'de', lng: 'German' },
{ value: 'en', lng: 'English' },
{ value: 'it', lng: 'Italian' }
];

const chooseLocale = async (locale: Locales) => {
await loadLocaleAsync(locale);
setLocale(locale);
};

let localeToSelect: Locales;
$: localeToSelect && chooseLocale(localeToSelect);

$: $locale && localStorage.setItem('lang', $locale);
</script>

<select bind:value={localeToSelect}>
<option value="" selected disabled>language selector</option>
{#each locales as locale, i}
<option value={locale}>{locale === lang[i].value ? lang[i].lng : locale}</option>
{/each}
</select>
1 change: 1 addition & 0 deletions src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { default as Steps } from './steps.svelte';
export { default as Step } from './step.svelte';
export { default as Code } from './code.svelte';
export { default as Json } from './json.svelte';
export { default as LanguageSelector } from './LanguageSelector.svelte';
export { default as CustomId } from './customId.svelte';
export { default as Secret } from './secret.svelte';
export { default as Trim } from './trim.svelte';
Expand Down
63 changes: 63 additions & 0 deletions src/lib/i18n/de/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
goswamianshuman marked this conversation as resolved.
Show resolved Hide resolved
"globals": {
"placeholders": {
"email": "E-Mail",
"password": "Passwort",
"enter_password": "Passwort eingeben",
"confirm_password": "Passwort bestätigen",
"your_name": "Ihr Name",
"your_email": "Ihre E-Mail-Adresse",
"your_password": "Ihr Passwort",
"your_code": "dein Code"
},
"update": "aktualisieren",
"recover": "genesen",
"accept": "akzeptieren",
"cancel": "stornieren"
},
goswamianshuman marked this conversation as resolved.
Show resolved Hide resolved
"login": {
"title": "anmelden",
"field_inputs": {
"email": "E-Mail",
"password": "Passwort"
}
},
"sign_up": {
"title": "Anmeldung",
"field_inputs": {
"name": "Name",
"email": "E-Mail",
"password": "Passwort",
"code": "Code"
},
"already_registered": "Sie haben bereits ein Konto?"
},
"password_recovery": {
"title": "Passwort-Wiederherstellung",
"forgot_password": "Passwort vergessen",
"field_inputs": {
"email": "E-Mail",
"new_password": "Neues Kennwort",
"cnf_password": "Bestätige das Passwort"
}
},
"accept_invite": {
"title": "Einladung annehmen",
"invalid_invite": "Ungültige Einladung",
"invite": "einladen",
"sign_up": "Melden Sie sich bei Appwrite an",
"warning_alert": {
"title": "Der Einladungslink ist ungültig",
"sub_title": "Bitten Sie den Projektinhaber, Ihnen eine neue Einladung zu senden."
},
"success_alert": {
"title": "Sie wurden eingeladen, an einem Teamprojekt auf Appwrite teilzunehmen"
}
},
"privacy_and_policy": {
"main_text": "Indem Sie die Einladung annehmen, erklären Sie sich damit einverstanden",
"terms_and_condition": "Geschäftsbedingungen",
"and": "Und",
"privacy_policy": "Datenschutz und Richtlinien"
}
}
6 changes: 6 additions & 0 deletions src/lib/i18n/de/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Translation } from '../i18n-types';
import deJson from './de.json';

const de: Translation = deJson;

export default de;
77 changes: 77 additions & 0 deletions src/lib/i18n/en/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"globals": {
"placeholders": {
"email": "Email",
"password": "Password",
"enter_password": "Enter Password",
"confirm_password": "Confirm Password",
"your_name": "Your name",
"your_email": "Your email",
"your_password": "Your password",
"your_code": "Your code",
"first_appwrite_project": "First Appwrite Project"
},
"update": "Update",
"recover": "Recover",
"accept": "Accept",
"cancel": "Cancel"
},
"login": {
"title": "Sign in",
"field_inputs": {
"email": "Email",
"password": "Password"
}
},
"sign_up": {
"title": "Sign up",
"field_inputs": {
"name": "Name",
"email": "Email",
"password": "Password",
"code": "code"
},
"already_registered": "Already got an account?"
},
"password_recovery": {
"title": "Password Recovery",
"forgot_password": "Forgot Password",
"field_inputs": {
"email": "Email",
"new_password": "New password",
"cnf_password": "Confirm password"
}
},
"accept_invite": {
"title": "Accept invite",
"invalid_invite": "Invalid invite",
"invite": "Invite",
"sign_up": "Sign up to Appwrite",
"warning_alert": {
"title": "The invite link is not valid",
"sub_title": "Please ask the project owner to send you a new invite."
},
"success_alert": {
"title": "You have been invited to join a team project on Appwrite"
}
},
"privacy_and_policy": {
"main_text": "By accepting the invitation, you agree to the",
"terms_and_condition": "Terms and Conditions",
"and": "and",
"privacy_policy": "Privacy and Policy"
},
"console": {
"onboarding": {
"header": "Onboarding",
"title": "Let's create your first project"
},
"basic_keywords": {
"project": "Project",
"project_name": "Project name",
"project_id": "Project ID",
"create_project": "Create Project"
}
}

}
6 changes: 6 additions & 0 deletions src/lib/i18n/en/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { BaseTranslation } from '../i18n-types';
import engJson from './en.json';

const en: BaseTranslation = engJson;

export default en;
11 changes: 11 additions & 0 deletions src/lib/i18n/formatters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { FormattersInitializer } from 'typesafe-i18n';
import { date } from 'typesafe-i18n/formatters';
import type { Formatters, Locales } from './i18n-types';

export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => {
const formatters: Formatters = {
weekday: date(locale, { weekday: 'long' })
};

return formatters;
};
Loading