locize / locize-examples

[DEPRECATED] examples for using locize in js todo app samples
9 stars 6 forks source link

Sample react 16.8 #2

Closed haf closed 5 years ago

haf commented 5 years ago

Hi,

Do you have a sample with i18next and latest react that doesn't use globals/window.locize? I would like to bundle everything with webpack.

Regards,

adrai commented 5 years ago

Something like this? https://github.com/i18next/react-i18next/tree/master/example/react/src + locize settings: https://github.com/i18next/react-i18next/blob/master/example/v9.x.x/locize/src/i18n.js

haf commented 5 years ago

@adrai Yes exactly that; I was avoiding older samples, but there it is.

Are there any details on how to set up a CI/CD pipeline with locize?

adrai commented 5 years ago

You have the possibility to use the cli (https://github.com/locize/locize-cli) or directly the api (https://docs.locize.com/integration/api).

And there are also webhooks (https://docs.locize.com/integration/webhook), slack (https://docs.locize.com/more/notifications), the saveMissing feature of i18next (https://www.i18next.com/overview/configuration-options#missing-keys), last used plugin (https://github.com/locize/locize-lastused), in-context-editor (https://docs.locize.com/more/incontext-editor), etc... 😉

haf commented 5 years ago

Ref https://github.com/locize/i18next-node-locize-backend/issues/3#issuecomment-462148036

haf commented 5 years ago

Ok, last question (promise!) the above but with next-i18next—next.js support as well? next-i18next doesn't really expose its i18n configuration in its sample.

jamuhl commented 5 years ago

https://github.com/isaachinman/next-i18next/blob/master/src/create-i18next-client.js#L30 there seems to be a use array you can pass for configuration

haf commented 5 years ago

@jamuhl I tried; the problem is that I have to conditionally only give it if it's running on the server.

EDIT:

// https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/locize
const defaultConfig = {
  defaultLanguage: 'en',
  otherLanguages: ['sv'],
  use: process.browser ? [] : [ require('i18next-node-locize-backend') ]
}

works, but it's badly configured and crashes when trying to read an absolute path:

Error: Invalid URI "/Users/h/dev/qv2/static/locales/en/common.json"
jamuhl commented 5 years ago

looks more like the default setting for the i18next-fs-backend triggers here -> did you pass in the backend settings for the i18next-node-locize-backend?

haf commented 5 years ago

I've tried both as a property backend on the config object, and

image

both throw the above error.

jamuhl commented 5 years ago

I would ask how to do it properly at the next-i18next repo - @isaachinman for sure will help you out with this.

Alternative just sync your translations to the express server using our CLI: https://github.com/locize/locize-cli#download-current-published-files

haf commented 5 years ago

This all now works with these keys in config:

and these in backend:

Thanks for helping me getting it working. If you want to track this issue as "add a react sample", feel free to reopen.

datainvestor commented 2 years ago

Did you manage to use in context editor with NextJS?

adrai commented 2 years ago

Did you manage to use in context editor with NextJS?

just use it like this: https://github.com/locize/next-i18next-locize/blob/main/next-i18next.config.js#L27