Closed KaMeHb-UA closed 6 years ago
Thanks for asking!😀 I assume that you are using the last version of React Social Network
. To set a new language:
en.json
in locale folder then rename with the convention {country language code}.json. ( For your case the name of your file would be ru.json
). Then translate the file in your language.ru.json
in localSaga.ts.
initLocalization()
function add the object { name: 'Russian', code: LanguageType.Russian }
to const languages = [ ]
array. const russianLocale = require('locale/ru.json')
which import your file in localeSaga
yield put(addTranslationForLanguage(russianLocale, LanguageType.Russian))
to add your language in Redux Store.With this you have your language installed. 👍
However for the debug TypeError: Cannot read property 'code' of undefined
mostly cause if you don't use Immutable function to get code
value.
So please be sure in HomeComponent mapStateToProps() instead of bellow code:
getActiveLanguage(state.locale).code,
You should use :
getActiveLanguage(state.get('locale')).code
As state is Immutable so you need to use get()
function to access value.
Let me know if any issue.
Yeah, it's done! Thanks for quick reply!
I had look on
src/reducers/locale/languageType.ts
and found my language described (russian), so I createdsrc/locale/ru.json
similar tosrc/locale/en.json
and changed exportedenvironment.settings.defaultLanguage
toLanguageType.Russian
insrc/config/environment.dev.ts
, but got next error:What I'm doing wrong?