You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CI4: Modify Weblate config to work with CI4 style language strings. #3468
Unlike CI3, CI4 ranges translation phrases into an associative array. I'm not sure of the ingest/export mechanism of Weblate but we may need to tweak the configuration so that translation files get generated properly.
Also, currently only en-US language files in #3271 has been ported to the CI4 format. We need to figure out if we have to convert the rest of them by hand or if weblate can do this for us.
@objecttothis aren't the language files already associative arrays at this point? We have a lang variable (array) with key and assign a value to it. The syntax you show here will probably yield the same result?
@objecttothis aren't the language files already associative arrays at this point? We have a lang variable (array) with key and assign a value to it. The syntax you show here will probably yield the same result?
Sorry, you are correct. There are two things to consider though:
In order to keep the CI3 styling we need to add return $lang;to the bottom of each file. Can we customize Weblate's generator to do this?
By not adopting CI4 styling we could face hiccups later. In the end it's not a big deal because both are valid associative arrays, but it won't match CI documentation from here on out.
#1 Is the only "must do" I think. If it's a lot of work to switch the array notation style in weblate then I'm ok with leaving it and adding the return statement. Let me know what you want to do.
@objecttothis I need to take some time to see how the file load mechanism works exactly. I suppose in the past CI was just loading one file and thus overwriting the keys with new values every time a language was selected.
Do we keep the MY_Lang extension that we had in the old install or do we need to modify it? If we keep it then we can probably bootstrap the existing files and then we're also certain it will work with weblate. I wouldn't really worry too much about the CI convention here, as long as the strings go where they should.
I'll be off coming week on a hiking trip, so I might not be able to look into this until after then.
https://codeigniter.com/user_guide/installation/upgrade_localization.html gives the details of upgrading localization. The extensions of localizations that we did in 3.x is one of the things that I am unfamiliar with. I'm certainly not opposed to extending and overriding CI4 functionality, but I don't think it's a good idea to do it just to avoid code rewrites because it opens the software up to difficulty upgrading in the future and potentially vulnerability patches that CI4 makes in x area that we aren't taking advantage of because we've overridden functionality in that area.
That said, I haven't yet looked at porting the various framework extensions that we've made, so I guess we need to create an issue for that one too.
@objecttothis Good point indeed, let's not extend it unless there is no other way. I'll have to look in to the customization to see what it does exactly and will then check how to accomplish the same behavior in CI4.
An easy fix for the language files would be to add an array declaration at the top of all the files, $lang = [] and a return $lang at the end.
@objecttothis Good point indeed, let's not extend it unless there is no other way. I'll have to look in to the customization to see what it does exactly and will then check how to accomplish the same behavior in CI4.
An easy fix for the language files would be to add an array declaration at the top of all the files, $lang = [] and a return $lang at the end.
OK, let's see what ends up being needed. I converted all the files for en-US by hand already to the CI4 format, but that can be reverted if we find that Weblate cannot easily output that format for all the other languages and it's possible to use the CI3 formatting in CI4. It sounds like CI3 formatting could be made to work with your suggestion here.
Activity
objecttothis commentedon Apr 12, 2022
Also, currently only en-US language files in #3271 has been ported to the CI4 format. We need to figure out if we have to convert the rest of them by hand or if weblate can do this for us.
jekkos commentedon Apr 12, 2022
@objecttothis aren't the language files already associative arrays at this point? We have a lang variable (array) with key and assign a value to it. The syntax you show here will probably yield the same result?
jekkos commentedon Apr 12, 2022
I could look into this but preferably I'll try to match with what is in weblate as the current format nicely works.
objecttothis commentedon Apr 12, 2022
Sorry, you are correct. There are two things to consider though:
return $lang;to the bottom of each file. Can we customize Weblate's generator to do this?#1 Is the only "must do" I think. If it's a lot of work to switch the array notation style in weblate then I'm ok with leaving it and adding the return statement. Let me know what you want to do.
jekkos commentedon Apr 13, 2022
@objecttothis I need to take some time to see how the file load mechanism works exactly. I suppose in the past CI was just loading one file and thus overwriting the keys with new values every time a language was selected.
Do we keep the MY_Lang extension that we had in the old install or do we need to modify it? If we keep it then we can probably bootstrap the existing files and then we're also certain it will work with weblate. I wouldn't really worry too much about the CI convention here, as long as the strings go where they should.
I'll be off coming week on a hiking trip, so I might not be able to look into this until after then.
objecttothis commentedon Apr 14, 2022
From https://codeigniter.com/user_guide/installation/upgrade_4xx.html


https://codeigniter.com/user_guide/installation/upgrade_localization.html gives the details of upgrading localization. The extensions of localizations that we did in 3.x is one of the things that I am unfamiliar with. I'm certainly not opposed to extending and overriding CI4 functionality, but I don't think it's a good idea to do it just to avoid code rewrites because it opens the software up to difficulty upgrading in the future and potentially vulnerability patches that CI4 makes in x area that we aren't taking advantage of because we've overridden functionality in that area.
That said, I haven't yet looked at porting the various framework extensions that we've made, so I guess we need to create an issue for that one too.
jekkos commentedon Apr 14, 2022
@objecttothis Good point indeed, let's not extend it unless there is no other way. I'll have to look in to the customization to see what it does exactly and will then check how to accomplish the same behavior in CI4.
An easy fix for the language files would be to add an array declaration at the top of all the files,
$lang = []and areturn $langat the end.objecttothis commentedon Apr 14, 2022
OK, let's see what ends up being needed. I converted all the files for en-US by hand already to the CI4 format, but that can be reverted if we find that Weblate cannot easily output that format for all the other languages and it's possible to use the CI3 formatting in CI4. It sounds like CI3 formatting could be made to work with your suggestion here.
jekkos commentedon May 1, 2022
I'lll try to have a look later this week.
jekkos commentedon Oct 19, 2022
@objecttothis it seems the CI4 format is also supported by weblate
jekkos commentedon Oct 19, 2022
objecttothis commentedon Oct 19, 2022
That's great news.
193 remaining items
Sync language files (#3468)
Use double quotes in language files (#3468)
Reinstate en-US files (#3468)
Add CI4 language migration scripts (#3468)
Sync language files (#3468)
Fix string escape (#3468)
Sync language files (#3468)
Sync language files (#3468)
Reinstate required_username translation (#3468)
Reinstate required_username translation (#3468)
Fix translations file format (#3468)
Fix translations file format (#3468)
jekkos commentedon Sep 8, 2024
Weblate should be setup to receive translation contributions on master.. seems the translation type was not set correctly yet
Sync language files (#3468)
Sync language files (#3468)