Updated i18n to use multiple domains

This commit is contained in:
Duncan Sommerville 2014-11-04 16:57:40 -05:00
parent 057993eeeb
commit 5275669211
5 changed files with 23 additions and 7 deletions

View file

@ -11,6 +11,7 @@ require_once __DIR__."/configs/constants.php";
require_once 'Preference.php'; require_once 'Preference.php';
require_once 'Locale.php'; require_once 'Locale.php';
require_once "DateHelper.php"; require_once "DateHelper.php";
require_once "LocaleHelper.php";
require_once "OsPath.php"; require_once "OsPath.php";
require_once "Database.php"; require_once "Database.php";
require_once "Timezone.php"; require_once "Timezone.php";

View file

@ -2,6 +2,7 @@
class LocaleController extends Zend_Controller_Action class LocaleController extends Zend_Controller_Action
{ {
public function init() public function init()
{ {
} }

View file

@ -2,6 +2,11 @@
class Application_Model_Locale class Application_Model_Locale
{ {
private static $domains = [
'airtime',
'pro',
];
public static $locales = array( public static $locales = array(
"en_CA" => "English (Canada)", "en_CA" => "English (Canada)",
"en_GB" => "English (Britain)", "en_GB" => "English (Britain)",
@ -48,10 +53,14 @@ class Application_Model_Locale
Logging::warn("Your system does not have the " . $lang . " locale installed. Run: sudo locale-gen " . $lang); Logging::warn("Your system does not have the " . $lang . " locale installed. Run: sudo locale-gen " . $lang);
} }
$domain = 'airtime'; // We need to run bindtextdomain and bind_textdomain_codeset for each domain we're using.
foreach (self::$domains as $domain) {
bindtextdomain($domain, '../locale'); bindtextdomain($domain, '../locale');
textdomain($domain);
bind_textdomain_codeset($domain, $codeset); bind_textdomain_codeset($domain, $codeset);
} }
textdomain('airtime');
}
} }

View file

@ -4,11 +4,11 @@
$topTextClass = ""; $topTextClass = "";
if (array_key_exists("planupdated", $_GET)) if (array_key_exists("planupdated", $_GET))
{ {
$topText = _("<b>Thank you!</b> Your plan has been updated and you will be invoiced during your next billing cycle."); $topText = _pro("<b>Thank you!</b> Your plan has been updated and you will be invoiced during your next billing cycle.");
$topTextClass = "status-good"; $topTextClass = "status-good";
} }
else { else {
$topText = _("Tip: To pay an invoice, click \"View Invoice\"<br> and look for the \"Checkout\" button."); $topText = _pro("Tip: To pay an invoice, click \"View Invoice\"<br> and look for the \"Checkout\" button.");
} }
?> ?>

View file

@ -5,10 +5,15 @@ cd ..
#generate a new .po file #generate a new .po file
#this will generate a file called messages.po #this will generate a file called messages.po
find . -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 find . -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8
find . -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 -k --keyword=_pro:1 -d pro --force-po
#merge the new messages from messages.po into each existing .po file #merge the new messages from messages.po into each existing .po file
#this will generate new .po files #this will generate new .po files
find ./airtime_mvc/locale/ -name "*.po" -exec msgmerge -N -U --no-wrap "{}" messages.po \; find ./airtime_mvc/locale/ -name "airtime.po" -exec msgmerge -N -U --no-wrap "{}" messages.po \;
find ./airtime_mvc/locale/ -name "pro.po" -exec msgmerge -N -U --no-wrap "{}" pro.po \;
#delete the old .po files #delete the old .po files
find ./airtime_mvc/locale/ -name "*.po~" -delete find ./airtime_mvc/locale/ -name "*.po~" -delete
#delete the temporary po files we create in the root directory
rm ./*.po