Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Language string changes for adherence to .ini file format spec
A late-breaking change in Textpattern 4.9.0 has landed. While it won’t require any changes to existing code or plugins, it’s something to be aware of.
The high-level takeaway is that the .ini file format forbids keys named using the following reserved words:
- no
- yes
- on
- off
- true
- false
- none
- null
We use five of those in our Textpack .ini files so I’ve renamed the offending keys with a prefix: txp_no
, txp_yes
, etc. This permits adherence to the spec and also opens the gates to use things like PHP’s parse_ini_file()
function, which failed on our Textpacks.
As the commit message says, these string keys are gracefully transformed on your behalf so you can continue to use gTxt('no')
(although gTxt('txp_no')
will work fine). The Textpack strings are in alphabetical order within areas, but the txp_ prefixed ones have been left in the position they were, as an indication that the prefix can be considered invisible.
The Textpack repo has been updated and the changes flushed downstream to core, BUT I’m not sure of the ramifications for CrowdIn. Hopefully Phil can advise here. I used a simple bunch of sed
commands to make the changes to the files:
find . -name '*.ini' | xargs sed -i.bu 's/^no=/txp_no=/'
rm *.bu
find . -name '*.ini' | xargs sed -i.bu 's/^yes=/txp_yes=/'
rm *.bu
...
but I expect it will be more involved on CrowdIn and may need doing manually for the 5 affected string keys. Depends if their API allows any scripting ability. Hopefully it’ll only need doing once for the English main file, which will trickle to the translations. I really hope each translation doesn’t need its own keys updating!
Apologies for the hack, but it is going to help us, as I’m writing some Textpack tools to help us move strings from section to section. It also gives us more scope to manipulate the Textpack files in better ways in future using built-in PHP INI functions.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Language string changes for adherence to .ini file format spec
As mentioned above, there’s a new tool available in the textpack repo for moving strings from group to group. Not expecting it to be needed much, but hopefully it’ll be useful for us if we want to migrate core strings from panel to panel or, more likely, to move ones from specific panels to the [admin-side]
or [common]
groups for more general availability.
It also reindexes the groups alphabetically. Not sure which order the strings come out of CrowdIn, but if php move-strings.php
is run vanilla after every CrowdIn resync, it will reindex the strings into a standard order.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline