-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add updated i18n config and en locale
- Loading branch information
Showing
90 changed files
with
2,678 additions
and
907 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,72 @@ | ||
import { PostProcessorModule } from 'i18next'; | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import en from './locales/en.json'; | ||
|
||
const resources = { | ||
en: { translation: en }, | ||
}; | ||
|
||
export const languages = [ | ||
{ | ||
label: 'English', | ||
value: 'en', | ||
}, | ||
]; | ||
|
||
const lowerCasePostProcessor: PostProcessorModule = { | ||
type: 'postProcessor', | ||
name: 'lowerCase', | ||
process: (value: string) => { | ||
return value.toLocaleLowerCase(); | ||
}, | ||
}; | ||
|
||
const upperCasePostProcessor: PostProcessorModule = { | ||
type: 'postProcessor', | ||
name: 'upperCase', | ||
process: (value: string) => { | ||
return value.toLocaleUpperCase(); | ||
}, | ||
}; | ||
|
||
const titleCasePostProcessor: PostProcessorModule = { | ||
type: 'postProcessor', | ||
name: 'titleCase', | ||
process: (value: string) => { | ||
return value.replace(/\w\S*/g, (txt) => { | ||
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase(); | ||
}); | ||
}, | ||
}; | ||
|
||
const sentenceCasePostProcessor: PostProcessorModule = { | ||
type: 'postProcessor', | ||
name: 'sentenceCase', | ||
process: (value: string) => { | ||
const sentences = value.split('. '); | ||
|
||
return sentences | ||
.map((sentence) => { | ||
return sentence.charAt(0).toUpperCase() + sentence.slice(1).toLocaleLowerCase(); | ||
}) | ||
.join('. '); | ||
}, | ||
}; | ||
i18n.use(lowerCasePostProcessor) | ||
.use(upperCasePostProcessor) | ||
.use(titleCasePostProcessor) | ||
.use(sentenceCasePostProcessor) | ||
.use(initReactI18next) // passes i18n down to react-i18next | ||
.init({ | ||
fallbackLng: 'en', | ||
// language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources | ||
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage | ||
// if you're using a language detector, do not define the lng option | ||
interpolation: { | ||
escapeValue: false, // react already safes from xss | ||
}, | ||
resources, | ||
}); | ||
|
||
export default i18n; |
Oops, something went wrong.
8430b1e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
feishin – ./
feishin-git-development-jeffvli.vercel.app
feishin-jeffvli.vercel.app
feishin.vercel.app