Skip to content

Conversation

LostKobrakai
Copy link
Contributor

Module authors can ship translations of their modules by adding a label => relative path combo to their module info block. Paths must be relative to the modules root directory. The files should be exported csv files of just the module translations.

Example info block:

'languages' => [
	'de_DE' => 'languages/de_DE.csv',
	'en' => 'languages/en.csv'
]

@mikerockett
Copy link

mikerockett commented Jan 26, 2017

I'm still not 100% knowledgeable about languages in PW, but does everyone use the same language keys? Like what happens if someone just uses de?


if($translated) {
// exclude modules without translations present
if(!$info['languages'] || !is_array($info['languages']) || !count($info['languages'])) continue;
Copy link
Contributor

@teppokoivula teppokoivula Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!count($info['languages']) is unnecessary since an empty array won't pass !$info['languages']. PHP converts (type juggles) an empty array to boolean FALSE and an array with items to boolean TRUE.

On the other hand you should first check if isset($info['languages']) or you might run into an E_NOTICE (undefined variable) :)

Copy link
Contributor Author

@LostKobrakai LostKobrakai Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, had that though yesterday evening as well. Might just use empty(), which covers the isset() as well as the count() issue.

@LostKobrakai
Copy link
Contributor Author

@mikerockett It's not automatically importing those translations. You can choose which translation file to import into which installed language. I just named my .csv's in the format of locales, so it's clear which kind of translation you can expect to import.

@LostKobrakai LostKobrakai force-pushed the feature/module-translation branch from 738cbee to 95ccf85 Compare January 26, 2017 08:08
@LostKobrakai LostKobrakai force-pushed the feature/module-translation branch from 95ccf85 to 1e5c7a7 Compare January 26, 2017 08:09
ryancramerdesign added a commit that referenced this pull request Jul 2, 2021
…slations, plus some related updates

Co-authored-by: LostKobrakai <benni@kobrakai.de>
@ryancramerdesign ryancramerdesign added the completed PR has been successfully added and this may be closed when ready. label Jul 2, 2021
@ryancramerdesign
Copy link
Member

Thanks @LostKobrakai I have added this, with a few changes and additions. Biggest differences are that I went without the 'languages' property added to the moduleInfo since I thought the files in the /languages/ directory were already enough. I also left out the "Translated" navigation option in the modules nav, as I guess I thought there wasn't enough need for it, but will add it back if I'm wrong about that. Thanks for the nice addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed PR has been successfully added and this may be closed when ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants