Commit 98e9c747 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added setup code for gettext

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