Merge pull request #1398 from jooola/feat/locale_management
Enhance locale management
This commit is contained in:
commit
8411c6225f
|
@ -1,12 +1,18 @@
|
||||||
SHELL = bash
|
SHELL = bash
|
||||||
|
|
||||||
all: vendor
|
all: vendor locale-build
|
||||||
|
|
||||||
PHP-CS-FIXER = tools/vendor/bin/php-cs-fixer
|
PHP-CS-FIXER = tools/vendor/bin/php-cs-fixer
|
||||||
$(PHP-CS-FIXER):
|
$(PHP-CS-FIXER):
|
||||||
mkdir -p tools
|
mkdir -p tools
|
||||||
composer require --working-dir=tools friendsofphp/php-cs-fixer
|
composer require --working-dir=tools friendsofphp/php-cs-fixer
|
||||||
|
|
||||||
|
include locale/Makefile
|
||||||
|
|
||||||
|
locale-update: .locale-update
|
||||||
|
locale-build:
|
||||||
|
$(MAKE) -C locale build
|
||||||
|
|
||||||
vendor:
|
vendor:
|
||||||
composer install --no-progress --no-interaction $(COMPOSER_ARGS)
|
composer install --no-progress --no-interaction $(COMPOSER_ARGS)
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
final class Application_Model_Locale
|
final class Application_Model_Locale
|
||||||
{
|
{
|
||||||
private static $domains = [
|
private static $domains = ['libretime'];
|
||||||
'airtime',
|
|
||||||
'pro',
|
|
||||||
];
|
|
||||||
|
|
||||||
public static $locales = [
|
public static $locales = [
|
||||||
'en_CA' => 'English (Canada)',
|
'en_CA' => 'English (Canada)',
|
||||||
|
@ -58,7 +55,7 @@ final class Application_Model_Locale
|
||||||
bind_textdomain_codeset($domain, $codeset);
|
bind_textdomain_codeset($domain, $codeset);
|
||||||
}
|
}
|
||||||
|
|
||||||
textdomain('airtime');
|
textdomain('libretime');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
.PHONY: .locale-update build
|
||||||
|
.DEFAULT: build
|
||||||
|
|
||||||
|
SHELL = bash
|
||||||
|
|
||||||
|
DOMAIN = libretime
|
||||||
|
PO_FILE = $(DOMAIN).po
|
||||||
|
PO_FILES = $(wildcard */LC_MESSAGES/$(PO_FILE))
|
||||||
|
MO_FILES = $(PO_FILES:.po=.mo)
|
||||||
|
|
||||||
|
SRC = application build public
|
||||||
|
|
||||||
|
XGETTEXT_ARGS = --default-domain=$(DOMAIN) \
|
||||||
|
--language=php \
|
||||||
|
--from-code=UTF-8 \
|
||||||
|
--no-wrap \
|
||||||
|
--sort-by-file
|
||||||
|
|
||||||
|
MSGMERGE_ARGS = --no-fuzzy-matching \
|
||||||
|
--update \
|
||||||
|
--no-wrap \
|
||||||
|
--sort-by-file
|
||||||
|
|
||||||
|
# This target is run by another Makefile
|
||||||
|
.locale-update:
|
||||||
|
find $(SRC) -name "*.phtml" -o -name "*.php" -type f -print0 | xargs -0 xgettext $(XGETTEXT_ARGS)
|
||||||
|
sed -i 's/CHARSET/UTF-8/g' $(PO_FILE)
|
||||||
|
find ./locale -name $(PO_FILE) -exec msgmerge $(MSGMERGE_ARGS) "{}" $(PO_FILE) \;
|
||||||
|
rm $(PO_FILE)
|
||||||
|
|
||||||
|
%.mo: %.po
|
||||||
|
msgfmt $< -o $@
|
||||||
|
|
||||||
|
build: $(MO_FILES)
|
Loading…
Reference in New Issue