Jump to content

Add translation file to module?


steveooo
 Share

Recommended Posts

Hello guys,

When developing a module, you can make the module support multi-language by using __() etc.

Is there a way / standard to add some language .json files to the module folder for ProcessWire to import automatically?

Or do I always have to import these language files manually?

Great would be:

My finished module auto-imports a translations.json file in the module's directory on initial install.

Maybe some standards like https://en.wikipedia.org/wiki/ISO_639-1 so ProcessWire can iterate through the translations.json and checks if each language is installed. If so, then PW automatically imports the needed json language data for this specific language.

Thanks for your answers!

Steve

Link to comment
Share on other sites

You're mentioning exactly the point, which does prevent that. It would need some kind of standard about language naming and that one is simply not existing in processwire (and even might not in the future). Languages (besides default) can be named however the admin does feel like. You could always implement a custom function into the install() method to check for languages named correctly and if so install any files. Other people would need to install them manually. 

Also a point about the default language. This one can be any language, but it's always named default. That's a problem as well.

  • Like 1
Link to comment
Share on other sites

There's a point though. Perhaps a ISO language code dropdown could be added to the language template together with a checkbox to allow automatic installation of language packs by new modules according to the selected value. This would keep backwards compatiblity yet allow for automatic installation (through module install). Adding a mechanism to query installed modules whether they provide translation packages for newly added languages could be accomplished by hooking Languages::added.

The only problem I see are languages that differ quite a bit in ISO 639-1 groups, which, for example, captures all variants of Chinese under the lable zh. Yet ISO 639-3 may be too fine-grained. A two-part solution like Unix and Windows use would IMHO be better (e.g. zh-cn, de-de, with fallback to the first two letters).

  • Like 1
Link to comment
Share on other sites

  • 5 years later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...