about summary refs log tree commit diff
path: root/src/state
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-11-20 13:29:27 -0800
committerGitHub <noreply@github.com>2023-11-20 13:29:27 -0800
commitc5b6f88e9a694d79126af4f742e66833dfd528bd (patch)
tree0bfdc49ace558adc3d9d5a76fc4726f16f853d4e /src/state
parent019aae5f01cb7b503d242917ae0092c2818f3b71 (diff)
downloadvoidsky-c5b6f88e9a694d79126af4f742e66833dfd528bd.tar.zst
Hindi Internationalization (#1914)
* get basic hindi support to work

* get web app language switcher in

* Refactor i18n implementation and remove unused
code

* add missing strings

* add dropdowns and modals missing strings

* complete all hindi translations

* fix merge conflicts

* fix legeacy persisted state

* fix data in RecommendedFeeds

* fix lint
Diffstat (limited to 'src/state')
-rw-r--r--src/state/persisted/legacy.ts2
-rw-r--r--src/state/persisted/schema.ts2
-rw-r--r--src/state/preferences/languages.tsx5
3 files changed, 9 insertions, 0 deletions
diff --git a/src/state/persisted/legacy.ts b/src/state/persisted/legacy.ts
index fefa7f372..79e8810b3 100644
--- a/src/state/persisted/legacy.ts
+++ b/src/state/persisted/legacy.ts
@@ -94,6 +94,8 @@ export function transform(legacy: Partial<LegacySchema>): Schema {
       postLanguageHistory:
         legacy.preferences?.postLanguageHistory ||
         defaults.languagePrefs.postLanguageHistory,
+      appLanguage:
+        legacy.preferences?.postLanguage || defaults.languagePrefs.appLanguage,
     },
     requireAltTextEnabled:
       legacy.preferences?.requireAltTextEnabled ||
diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts
index 93547aa5b..71f9bd545 100644
--- a/src/state/persisted/schema.ts
+++ b/src/state/persisted/schema.ts
@@ -30,6 +30,7 @@ export const schema = z.object({
     contentLanguages: z.array(z.string()), // should move to server
     postLanguage: z.string(), // should move to server
     postLanguageHistory: z.array(z.string()),
+    appLanguage: z.string(),
   }),
   requireAltTextEnabled: z.boolean(), // should move to server
   mutedThreads: z.array(z.string()), // should move to server
@@ -58,6 +59,7 @@ export const defaults: Schema = {
     postLanguageHistory: (deviceLocales || [])
       .concat(['en', 'ja', 'pt', 'de'])
       .slice(0, 6),
+    appLanguage: deviceLocales[0] || 'en',
   },
   requireAltTextEnabled: false,
   mutedThreads: [],
diff --git a/src/state/preferences/languages.tsx b/src/state/preferences/languages.tsx
index 95cf67417..8e779cfe5 100644
--- a/src/state/preferences/languages.tsx
+++ b/src/state/preferences/languages.tsx
@@ -11,6 +11,7 @@ type ApiContext = {
   toggleContentLanguage: (code2: string) => void
   togglePostLanguage: (code2: string) => void
   savePostLanguageToHistory: () => void
+  setAppLanguage: (code2: string) => void
 }
 
 const stateContext = React.createContext<StateContext>(
@@ -22,6 +23,7 @@ const apiContext = React.createContext<ApiContext>({
   toggleContentLanguage: (_: string) => {},
   togglePostLanguage: (_: string) => {},
   savePostLanguageToHistory: () => {},
+  setAppLanguage: (_: string) => {},
 })
 
 export function Provider({children}: React.PropsWithChildren<{}>) {
@@ -104,6 +106,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
             .slice(0, 6),
         }))
       },
+      setAppLanguage(code2: string) {
+        setStateWrapped(s => ({...s, appLanguage: code2}))
+      },
     }),
     [state, setStateWrapped],
   )