Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations #12

Closed
wants to merge 7 commits into from
Closed

Add translations #12

wants to merge 7 commits into from

Conversation

felixb-wix
Copy link
Contributor

@felixb-wix felixb-wix commented May 2, 2019

Resolves #5 (see for details)

Limitations:

@salickc
Copy link
Contributor

salickc commented May 3, 2019

@felixb-wix I was under the impression that translations should work out of the box using the i18n provider that all Wix projects are using today. We shouldn't write our own localization solution

import * as i18next from 'i18next';
import * as i18nextXHRBackend from 'i18next-xhr-backend';

// initializing i18n
export default function i18n({locale, baseUrl = ''}) {
  return i18next
    .use(i18nextXHRBackend)
    .init({
      lng: locale,
      fallbackLng: 'en',
      keySeparator: '$',
      interpolation: {
        escapeValue: false
      },
      react: {
        wait: true
      },
      backend: {
        loadPath: `${baseUrl}assets/locale/messages_{{lng}}.json`,
        crossDomain: true
      }
    });
}

// rendering i18n provider
import {I18nextProvider} from 'react-i18next';
ReactDOM.render(
<I18nextProvider i18n={i18n({locale, baseUrl: staticsBaseUrl})}>
    <...>
</I18nextProvider/>)

// get i18n t
import {t} from 'i18next';
t(...)

@felixb-wix
Copy link
Contributor Author

@salick I did what we discussed in #5. The comment above is a completely different solution. Let's talk about it.

@felixb-wix
Copy link
Contributor Author

The I18n implementation isn't right, and interceptors implementation was moved to a separate PR #13

@felixb-wix felixb-wix closed this May 6, 2019
@amiryonatan amiryonatan deleted the add-translations branch July 8, 2019 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement translations
2 participants