Creating a Translation File for MT-Notifier
Now that you can (somewhat) easily create an alternate request template for MT-Notifier, it's only natural that there are some of you out there who might want to translate the thing into different languages. Luckily, translating MT-Notifier has been possible for quite some time. In fact, some form of translation hooks have been present in the code since way back in version 2.0.1, released in 2004!
Unfortunately, that doesn't mean that the translation has always worked since then - but I've done my best to make sure that everything was in place so that it would work when everything was functioning correctly, and lately it seems that just about everything has been doing just that. You do have to follow a few steps to make sure that your translation file works correctly, however. There are two places that your file will be used - inside the application and outside the application, and for this, there are two ways that you need to consider changes that you might make. Follow along to find out what you might need to do to make sure that your changes are being picked up by the plugin.
Step 1. The first thing that you need to do is create the translations. For this, start with the en_us.pm file, because it actually has everything in it that you will need - including the directions. These directions might not be as detailed as you need though, which is why I'm writing out the long version here. Inside this file, you will see a lexicon, which is a fancy name for a bunch of strings that will get translated. This is where the magic happens. I've done my best to break the strings into sections so that you know where to find each string based on where it appears in the application - no sense changing strings that you won't use.
For example, here are two of the most important ones - Subscription and Subscriptions. To change what they say, you'll want to change the value on the right side of the operator:
'Subscription' => 'Subscription',
'Subscriptions' => 'Subscriptions',
No matter which language you are translating, you never want to change the left side, as that's what Movable Type uses to find a match. Always change what is on the right side to the value you want, and by changing these values, you will get them to change to the value that you would like to see. Also note that the values that you change here are in effect only for times when MT-Notifier is running, and so if another plugin runs to generate the word Subscription, you might not see the change!
After you make the change, be sure that you do not remove the enclosing quotes ('') and also make sure that you have a trailing comma (,) at the end of the translation string. You also should try and use HTML entities wherever possible, rather than copying characters from Word or another editor. This is because some users may have trouble displaying those special characters, and HTML entities will give you the best possible chance of having a successful translation.
Step 2. Once you have translated all the stirngs you want to translate, you will need to save the file to the proper name and update it on your server. For instance, if you are creating a Spanish translation file, you will save the file as es.pm (the Spanish language code) and then upload it to your server. However, you also need to make two other changes within the file itself. These allow Movable Type to know that this is a package that is responsible for translating strings within the Spanish language. First, locate the package line near the top of the file:
package Notifier::L10N::en_us;
You will want to change it to include not en_us, but the language code of the language you are creating:
package Notifier::L10N::es;
Then you also need to update the use base line, just below that one:
use base 'Notifier::L10N';
This line tells the file what to do if it can't find any strings, and you should set it so that it looks at the en_us file by default. Simply change it to look there:
use base 'Notifier::L10N::en_us';
Now you're set to upload the file with your changes.
Step 3. This step is only needed if you will be using strings that are used when a user is not logged in - for instance, if you are updating the request strings (messages sent to users who are confirming their subscriptions). The issue is that translations are typically based on the logged-in user. But when a subscriber tries to confirm their request, they are not always going to be a logged-in user. In fact, they almost always will not be logged in. In that case, you will want to make sure that you have a default translation available for them, so you will need to set your configuration file appropriately. Just add this line to your mt-config.cgi file:
DefaultLanguage es
That way, when someone who is not logged in attempts to confirm their request, they will get translations based on the default language (in this case, es, or Spanish). If you do not do this, they will get the system default, which is en_us, or US English. There is not anything wrong with this, of cousre, but it will mean your hard translating work has gone to waste!
More Information on "MT-Notifier" »

Leave a comment