Persist locale in local storage
This commit is contained in:
parent
7faff0d4f3
commit
845d5186c9
2 changed files with 36 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"POT-Creation-Date: 2019-10-16T15:55:00.250Z\n"
|
"POT-Creation-Date: 2019-10-17T11:58:34.974Z\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -59,6 +59,14 @@ msgctxt "service account"
|
||||||
msgid "Account Name"
|
msgid "Account Name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: build/locale/src/components/AppLayout/AppLayout.json
|
||||||
|
#. [src.components.AppLayout.248888005] - button
|
||||||
|
#. defaultMessage is:
|
||||||
|
#. Account Settings
|
||||||
|
msgctxt "button"
|
||||||
|
msgid "Account Settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: build/locale/src/components/AccountStatus/AccountStatus.json
|
#: build/locale/src/components/AccountStatus/AccountStatus.json
|
||||||
#. [src.components.AccountStatus.2183517419] - section header
|
#. [src.components.AccountStatus.2183517419] - section header
|
||||||
#. defaultMessage is:
|
#. defaultMessage is:
|
||||||
|
@ -5755,6 +5763,22 @@ msgctxt "order payment"
|
||||||
msgid "Preauthorized amount"
|
msgid "Preauthorized amount"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: build/locale/src/staff/components/StaffPreferences/StaffPreferences.json
|
||||||
|
#. [src.staff.components.StaffPreferences.2340309446] - section header
|
||||||
|
#. defaultMessage is:
|
||||||
|
#. Preferences
|
||||||
|
msgctxt "section header"
|
||||||
|
msgid "Preferences"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: build/locale/src/staff/components/StaffPreferences/StaffPreferences.json
|
||||||
|
#. [src.staff.components.StaffPreferences.2281358617]
|
||||||
|
#. defaultMessage is:
|
||||||
|
#. Preferred Language
|
||||||
|
msgctxt "description"
|
||||||
|
msgid "Preferred Language"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: build/locale/src/products/components/ProductVariantCreateDialog/ProductVariantCreateDialog.json
|
#: build/locale/src/products/components/ProductVariantCreateDialog/ProductVariantCreateDialog.json
|
||||||
#. [src.products.components.ProductVariantCreateDialog.904693740] - previous step, button
|
#. [src.products.components.ProductVariantCreateDialog.904693740] - previous step, button
|
||||||
#. defaultMessage is:
|
#. defaultMessage is:
|
||||||
|
@ -7019,6 +7043,14 @@ msgctxt "description"
|
||||||
msgid "Selected {number} items"
|
msgid "Selected {number} items"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: build/locale/src/staff/components/StaffPreferences/StaffPreferences.json
|
||||||
|
#. [src.staff.components.StaffPreferences.1332294025]
|
||||||
|
#. defaultMessage is:
|
||||||
|
#. Selecting this will change the language of your dashboard
|
||||||
|
msgctxt "description"
|
||||||
|
msgid "Selecting this will change the language of your dashboard"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: build/locale/src/products/components/ProductVariantPrice/ProductVariantPrice.json
|
#: build/locale/src/products/components/ProductVariantPrice/ProductVariantPrice.json
|
||||||
#. [src.products.components.ProductVariantPrice.2238565650]
|
#. [src.products.components.ProductVariantPrice.2238565650]
|
||||||
#. defaultMessage is:
|
#. defaultMessage is:
|
||||||
|
|
|
@ -42,6 +42,7 @@ import locale_UK from "@locale/uk.json";
|
||||||
import locale_VI from "@locale/vi.json";
|
import locale_VI from "@locale/vi.json";
|
||||||
import locale_ZH_HANS from "@locale/zh-Hans.json";
|
import locale_ZH_HANS from "@locale/zh-Hans.json";
|
||||||
import locale_ZH_HANT from "@locale/zh-Hant.json";
|
import locale_ZH_HANT from "@locale/zh-Hant.json";
|
||||||
|
import useLocalStorage from "@saleor/hooks/useLocalStorage";
|
||||||
|
|
||||||
export enum Locale {
|
export enum Locale {
|
||||||
AR = "ar",
|
AR = "ar",
|
||||||
|
@ -208,7 +209,8 @@ export const LocaleContext = React.createContext<LocaleContextType>({
|
||||||
const { Consumer: LocaleConsumer, Provider: RawLocaleProvider } = LocaleContext;
|
const { Consumer: LocaleConsumer, Provider: RawLocaleProvider } = LocaleContext;
|
||||||
|
|
||||||
const LocaleProvider: React.FC = ({ children }) => {
|
const LocaleProvider: React.FC = ({ children }) => {
|
||||||
const [locale, setLocale] = React.useState(
|
const [locale, setLocale] = useLocalStorage(
|
||||||
|
"locale",
|
||||||
getMatchingLocale(navigator.languages) || defaultLocale
|
getMatchingLocale(navigator.languages) || defaultLocale
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue