-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
696 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
locales: ["en", "ja"], | ||
output: "src/i18n/translations/$LOCALE.yml", | ||
input: ["src/**/*.{ts,tsx}"], | ||
useKeysAsDefaultValue: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import i18n from "i18next"; | ||
import LanguageDetector from "i18next-browser-languagedetector"; | ||
import { initReactI18next } from "react-i18next"; | ||
|
||
import en from "./translations/en.yml"; | ||
import ja from "./translations/ja.yml"; | ||
|
||
const resources = { | ||
en: { | ||
translation: en, | ||
}, | ||
ja: { | ||
translation: ja, | ||
}, | ||
}; | ||
|
||
export const availableLanguages = Object.keys(resources); | ||
|
||
// eslint-disable-next-line import/no-named-as-default-member | ||
i18n.use(LanguageDetector).use(initReactI18next).init({ | ||
resources, | ||
fallbackLng: "en", | ||
keySeparator: false, | ||
returnEmptyString: false, | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { useTranslation } from "react-i18next"; | ||
export { default as Provider } from "./provider"; | ||
export { default as PublishedProvider } from "./publishedProvider"; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/locale/publishedProvider.tsx → src/i18n/legacy/publishedProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { ReactNode, useEffect } from "react"; | ||
import { I18nextProvider } from "react-i18next"; | ||
|
||
import { useAuth } from "@reearth/auth"; | ||
import { useLanguageQuery } from "@reearth/gql"; | ||
|
||
import i18n from "./i18n"; | ||
import { Provider as LegacyProvider } from "./legacy"; | ||
|
||
export default function Provider({ children }: { children?: ReactNode }) { | ||
const { isAuthenticated } = useAuth(); | ||
const { data } = useLanguageQuery({ skip: !isAuthenticated }); | ||
const locale = data?.me?.lang; | ||
|
||
useEffect(() => { | ||
i18n.changeLanguage(locale === "und" ? undefined : locale); | ||
}, [locale]); | ||
|
||
return ( | ||
<I18nextProvider i18n={i18n}> | ||
<LegacyProvider>{children}</LegacyProvider> | ||
</I18nextProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { ReactNode } from "react"; | ||
import { I18nextProvider } from "react-i18next"; | ||
|
||
import i18n from "./i18n"; | ||
import { PublishedProvider as LegacyProvider } from "./legacy"; | ||
|
||
export default function PublishedProvider({ children }: { children?: ReactNode }) { | ||
return ( | ||
<I18nextProvider i18n={i18n}> | ||
<LegacyProvider>{children}</LegacyProvider> | ||
</I18nextProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Continue: Continue | ||
Cancel: Cancel | ||
'''s workspace': '''s workspace' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Continue: キャンセル | ||
Cancel: 続ける | ||
'''s workspace': ' のワークスペース' |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.