Skip to content
Snippets Groups Projects
Commit 98e9c747 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Added setup code for gettext

parent 0964082f
No related branches found
No related tags found
No related merge requests found
......@@ -7,3 +7,5 @@ www/js/
www/css/
config.local.json
config.mk
*.po
locale/messages.mo
CACHE_DIR := .cache
WWW_DIR := www
LIB_DIR := vendor
SCRIPTS := forms scores
STYLES := main
CACHE_DIR := .cache
WWW_DIR := www
LIB_DIR := vendor
SCRIPTS := forms scores
STYLES := main
LOCALE_DIR := locale
LOCALES := nl_NL
GETTEXT_DOMAIN := archery
include config.mk # defines HTTPDUSER
SCRIPTS := $(patsubst %,$(WWW_DIR)/js/%.js,$(SCRIPTS))
STYLES := $(patsubst %,$(WWW_DIR)/css/%.css,$(STYLES))
.PHONY: all min clean cleaner
.PHONY: all min translations clean cleaner
all: $(LIB_DIR)/autoload.php $(CACHE_DIR) $(SCRIPTS) $(STYLES)
all: $(LIB_DIR)/autoload.php $(CACHE_DIR) $(SCRIPTS) $(STYLES) translations
# Dependencies
$(LIB_DIR)/autoload.php: $(LIB_DIR) composer.json
composer update
......@@ -19,6 +24,8 @@ $(LIB_DIR)/autoload.php: $(LIB_DIR) composer.json
$(LIB_DIR):
composer install
# JavaScript / CSS
$(WWW_DIR)/js/%.js: coffee/%.coffee
@mkdir -p $(@D)
coffee --compile --output $(@D) $<
......@@ -38,12 +45,31 @@ min: all
mv .tmp.js $$f; \
done
# Tmp files
$(CACHE_DIR):
mkdir $@
setfacl -R -m u:$(HTTPDUSER):rwX -- $@
# Gettext translations
SRC_FILES := $(wildcard *.php) $(wildcard routes/*.php)
#XXX: $(shell find templates -name \*.latte)
translations: $(patsubst %,$(LOCALE_DIR)/%/LC_MESSAGES/$(GETTEXT_DOMAIN).mo,$(LOCALES))
%.mo: %.po
msgfmt $< -o $@
.PRECIOUS: $(LOCALE_DIR)/%/LC_MESSAGES/$(GETTEXT_DOMAIN).po
$(LOCALE_DIR)/%/LC_MESSAGES/$(GETTEXT_DOMAIN).po: $(SRC_FILES)
@if [ ! -e $@ ]; then mkdir -p $(@D); touch $@; fi
xgettext -j -n -o $@ $^
# Cleanup
clean:
rm -f $(SCRIPTS) $(STYLES) *.bak
cleaner: clean
rm -rf $(CACHE_DIR) $(LIB_DIR)
rm -rf $(CACHE_DIR) $(LIB_DIR) `find $(LOCALE_DIR) -name *.mo`
......@@ -6,11 +6,17 @@ require 'DatabaseAuthenticator.php';
/*
* Set locale based on browser language specification
* XXX: use for gettext
*/
//if ($locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']))
// setlocale(LC_ALL, $locale, "$locale.utf8");
if ($locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
putenv("LANG=$locale");
setlocale(LC_ALL, $locale);
}
$domain = 'archery';
bindtextdomain($domain, __DIR__ . '/locale');
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
/*
* Config
......
......@@ -6,6 +6,7 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Archery scorekeeper</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<base href="{$config['root_url']}/">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment