From 7e417b8cf65f78f643426e20a715c8eac30d9bf1 Mon Sep 17 00:00:00 2001 From: Taiwen Date: Sat, 30 Aug 2014 00:38:43 +0800 Subject: [PATCH] Added locale css demonstration per #1195 --- lib/Pi/View/Helper/Css.php | 2 +- lib/Pi/View/Helper/I18n.php | 2 +- usr/theme/default/asset/locale/en/locale.css | 12 ++++++++++++ usr/theme/default/asset/locale/en/locale.js | 8 ++++++++ usr/theme/default/asset/locale/en/rtl.css | 4 ---- usr/theme/default/asset/locale/en/rtl.js | 1 - usr/theme/default/asset/locale/fa/locale.css | 12 ++++++++++++ usr/theme/default/asset/locale/fa/locale.js | 8 ++++++++ usr/theme/default/asset/locale/zh-cn/locale.css | 12 ++++++++++++ usr/theme/default/asset/locale/zh-cn/locale.js | 8 ++++++++ usr/theme/default/template/layout-admin.phtml | 3 +++ usr/theme/default/template/layout-front.phtml | 3 +++ usr/theme/default/template/layout-simple.phtml | 5 ++++- usr/theme/default/template/layout-style.phtml | 2 +- usr/theme/pi/template/layout-front.phtml | 2 ++ 15 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 usr/theme/default/asset/locale/en/locale.css create mode 100644 usr/theme/default/asset/locale/en/locale.js delete mode 100644 usr/theme/default/asset/locale/en/rtl.css delete mode 100644 usr/theme/default/asset/locale/en/rtl.js create mode 100644 usr/theme/default/asset/locale/fa/locale.css create mode 100644 usr/theme/default/asset/locale/fa/locale.js create mode 100644 usr/theme/default/asset/locale/zh-cn/locale.css create mode 100644 usr/theme/default/asset/locale/zh-cn/locale.js diff --git a/lib/Pi/View/Helper/Css.php b/lib/Pi/View/Helper/Css.php index 64b50ad5c2..222a63213d 100644 --- a/lib/Pi/View/Helper/Css.php +++ b/lib/Pi/View/Helper/Css.php @@ -26,7 +26,7 @@ * * // Load specific file with attributes * $this->css('some.css', - * array('conditional' => '...', 'postion' => 'prepend')); + * array('conditional' => '...', 'position' => 'prepend')); * * // Load a list of files * $this->css(array( diff --git a/lib/Pi/View/Helper/I18n.php b/lib/Pi/View/Helper/I18n.php index 2662be22e1..bdfa91e14c 100644 --- a/lib/Pi/View/Helper/I18n.php +++ b/lib/Pi/View/Helper/I18n.php @@ -19,7 +19,7 @@ * Usage inside a phtml template * * ``` - * $this->i18n('theme/default', 'main'); + * $this->i18n('theme/default', 'default'); * $this->i18n('module/demo', 'block'); * ``` * diff --git a/usr/theme/default/asset/locale/en/locale.css b/usr/theme/default/asset/locale/en/locale.css new file mode 100644 index 0000000000..852fc46e66 --- /dev/null +++ b/usr/theme/default/asset/locale/en/locale.css @@ -0,0 +1,12 @@ +/** + * Locale css file + * + * Load in a theme template + * ``` + * $this->css($this->assetLocale('locale.css')); + * ``` + */ +.rtl { + direction: RTL; + unicode-bidi: embed; +} \ No newline at end of file diff --git a/usr/theme/default/asset/locale/en/locale.js b/usr/theme/default/asset/locale/en/locale.js new file mode 100644 index 0000000000..4c31240046 --- /dev/null +++ b/usr/theme/default/asset/locale/en/locale.js @@ -0,0 +1,8 @@ +/** + * Locale js file + * + * Load in a theme template + * ``` + * $this->js($this->assetLocale('locale.js')); + * ``` + */ \ No newline at end of file diff --git a/usr/theme/default/asset/locale/en/rtl.css b/usr/theme/default/asset/locale/en/rtl.css deleted file mode 100644 index dcad606a72..0000000000 --- a/usr/theme/default/asset/locale/en/rtl.css +++ /dev/null @@ -1,4 +0,0 @@ -.rtl { - direction: RTL; - unicode-bidi: embed; -} \ No newline at end of file diff --git a/usr/theme/default/asset/locale/en/rtl.js b/usr/theme/default/asset/locale/en/rtl.js deleted file mode 100644 index 640e6a0745..0000000000 --- a/usr/theme/default/asset/locale/en/rtl.js +++ /dev/null @@ -1 +0,0 @@ -/* For locale asset test */ \ No newline at end of file diff --git a/usr/theme/default/asset/locale/fa/locale.css b/usr/theme/default/asset/locale/fa/locale.css new file mode 100644 index 0000000000..852fc46e66 --- /dev/null +++ b/usr/theme/default/asset/locale/fa/locale.css @@ -0,0 +1,12 @@ +/** + * Locale css file + * + * Load in a theme template + * ``` + * $this->css($this->assetLocale('locale.css')); + * ``` + */ +.rtl { + direction: RTL; + unicode-bidi: embed; +} \ No newline at end of file diff --git a/usr/theme/default/asset/locale/fa/locale.js b/usr/theme/default/asset/locale/fa/locale.js new file mode 100644 index 0000000000..4c31240046 --- /dev/null +++ b/usr/theme/default/asset/locale/fa/locale.js @@ -0,0 +1,8 @@ +/** + * Locale js file + * + * Load in a theme template + * ``` + * $this->js($this->assetLocale('locale.js')); + * ``` + */ \ No newline at end of file diff --git a/usr/theme/default/asset/locale/zh-cn/locale.css b/usr/theme/default/asset/locale/zh-cn/locale.css new file mode 100644 index 0000000000..852fc46e66 --- /dev/null +++ b/usr/theme/default/asset/locale/zh-cn/locale.css @@ -0,0 +1,12 @@ +/** + * Locale css file + * + * Load in a theme template + * ``` + * $this->css($this->assetLocale('locale.css')); + * ``` + */ +.rtl { + direction: RTL; + unicode-bidi: embed; +} \ No newline at end of file diff --git a/usr/theme/default/asset/locale/zh-cn/locale.js b/usr/theme/default/asset/locale/zh-cn/locale.js new file mode 100644 index 0000000000..4c31240046 --- /dev/null +++ b/usr/theme/default/asset/locale/zh-cn/locale.js @@ -0,0 +1,8 @@ +/** + * Locale js file + * + * Load in a theme template + * ``` + * $this->js($this->assetLocale('locale.js')); + * ``` + */ \ No newline at end of file diff --git a/usr/theme/default/template/layout-admin.phtml b/usr/theme/default/template/layout-admin.phtml index 5cc92f138d..703f6b244e 100644 --- a/usr/theme/default/template/layout-admin.phtml +++ b/usr/theme/default/template/layout-admin.phtml @@ -24,6 +24,9 @@ $this->bootstrap(array( // Load admin.css $this->css($this->assetTheme('css/admin.css')); +// Load localization css +$this->css($this->assetLocale('locale.css')); + // Explicitly load favicon // @see http://en.wikipedia.org/wiki/Favicon $this->headLink(array( diff --git a/usr/theme/default/template/layout-front.phtml b/usr/theme/default/template/layout-front.phtml index 8feeb86c3f..c073f00a17 100644 --- a/usr/theme/default/template/layout-front.phtml +++ b/usr/theme/default/template/layout-front.phtml @@ -24,6 +24,9 @@ $this->bootstrap(array( // Load front.css $this->css($this->assetTheme('css/front.css')); +// Load localization css +$this->css($this->assetLocale('locale.css')); + // Apple icons // Apple icon for iphone $this->headLink(array( diff --git a/usr/theme/default/template/layout-simple.phtml b/usr/theme/default/template/layout-simple.phtml index 5deee8071f..04ad413781 100644 --- a/usr/theme/default/template/layout-simple.phtml +++ b/usr/theme/default/template/layout-simple.phtml @@ -24,6 +24,9 @@ $this->bootstrap(array( // Load front.css $this->css($this->assetTheme('css/front.css')); +// Load localization css +$this->css($this->assetLocale('locale.css')); + // Apple icons // Apple icon for iphone $this->headLink(array( @@ -96,7 +99,7 @@ $module = Pi::service('module')->current();
- + > diff --git a/usr/theme/default/template/layout-style.phtml b/usr/theme/default/template/layout-style.phtml index 88eada9f52..c7269c1e37 100644 --- a/usr/theme/default/template/layout-style.phtml +++ b/usr/theme/default/template/layout-style.phtml @@ -31,7 +31,7 @@ $module = Pi::service('module')->current();
- + > diff --git a/usr/theme/pi/template/layout-front.phtml b/usr/theme/pi/template/layout-front.phtml index f3fa73d936..2fe731109c 100644 --- a/usr/theme/pi/template/layout-front.phtml +++ b/usr/theme/pi/template/layout-front.phtml @@ -18,6 +18,8 @@ $this->bootstrap(array( 'font-awesome/css/font-awesome.min.css' )); $this->css($this->assetTheme('css/front.css')); +$this->css($this->assetLocale('locale.css')); + $this->headLink(array( 'rel' => 'apple-touch-icon', 'href' => $this->assetTheme('image/touch-icon-iphone.png')