Documentation for the Textpattern plugin smd_babel by Stef Dawson follows this short message from our sponsor ;-)
If you like my code and it soothes an otherwise unscratchable itch, feel free to show your appreciation with something from my UK Amazon wish list (or US) or donate to the Stef Dawson community coding pot, either via paypal.me/stefdawson or by following the Donate button below to PayPal. Thanks!
Managing translation strings in Textpattern has traditionally meant going into the database and fiddling with content there. This is no longer the case. Welcome… smd_babel.
Download a copy of the .txt file, visit your Textpattern Admin->Plugins panel and paste the contents into the Install plugin box. Submit and verify the plugin, then simply enable it by tapping the No/Yes toggle alongside the plugin’s name.
When the plugin is active, visit the Admin->Translations panel. You will see:
All strings are separated into groups (a.k.a events). For core strings, these usually equate to the panel names, e.g. ‘image’ for the strings that are used on the Images panel, ‘admin’ for those that appear on the Users panel, and so on.
Plugins normally group strings by their plugin name. There are three special groups:
admin-side: Strings in this group are available across the entire administration side. Usual things here are menu styrings, or items that are used on more than one panel.
public: Strings that are only loaded on the public site.
common: Strings that are common to both the entire admin-side AND are loaded on the public website.
When choosing a group, use the most appropriate group for the task. Don’t just assign everything to
common because that bulks up the amount of data sent on every page request, which slows down the website.
Selecting a group from the dropdown list will load strings from that group into the remainder of the panel.
This is where translation takes place, and it’s sub-divided in up to three columns:
- Site language: your default site language for the website is shown in the first column. This includes all translations for the keys in that group, and it also shows beneath each translation the key itself (for reference).
- Admin language: if your administration site language differs for your public website, the central column will appear that shows you translations for the currently selected group in your native admin language.
- Translation language: the final column is selectable. At the top is a language dropdown. Choose a language to load all the strings for that language into this column. Make amendments to any strings in the textareas. Simply altering the content and tabbing out of the box will commit the changes to the database for that string immediately.
You can switch language in the third column, or change groups at any time to update whichever strings are already present across the entire system.
If you wish to delete a string, click its corresponding ‘x’ icon in the first column. No warning is given, so be sure. Note that you cannot delete core strings.
If you wish to add a new string, you may do so by clicking the Add button in the top right of the panel. A popup box will appear permitting you to enter/select:
- The new key name. This must be unique. If you type in a key that already exists, its contents will be overwritten without warning!
- The group in which the key will appear. Default is the current group in which you are working.
- The language in which the new key will appear. Default is the current language that you are translating.
- The new string value: its translation.
Once done, click the Save button. Your string will be added to the database. Note that it won’t appear in the table until you refresh the panel. This permits you to rapidly add more than one string in succession by just varying the key and translation.
To download the strings into a file, click the Export button. A popup box will permit you to choose:
- The group of strings you wish to download. Specify a comma-separated list of groups here, or empty the box if you wish to download all strings.
- The language of the strings you wish to export.
- A string (key) match.
Once you have selected the criteria, click Download to save the file to your computer.
For example, if you wished to download all strings used by this plugin you would supply:
That ensures you only get the keys matching
smd_babel from the admin-side group, otherwise you’d get all of the strings from this group – core and other plugins included.
If you’d rather scrabble amid the ones and noughts, you’ll need to step into the view source page.
If, for some inexplicable reason, you need an ancient version of a plugin, it can probably be found on the plugin archive page.
If you’re feeling brave, or fancy swimming with piranhas, you can test out some of my beta code. It can be found on the plugin beta page.