From b3bde618c1c24f3591f4a638b32aed3f7fd2829d Mon Sep 17 00:00:00 2001 From: Manuel Hiebel Date: Sun, 8 Jun 2014 15:17:54 +0000 Subject: sync nav --- css/center.css | 62 ++++++++++++++++++++++ css/index.php | 14 ++++- langs/ast.po | 101 ++++++++++++++++++++++++++++++++++++ langs/php-mo.php | 154 ------------------------------------------------------- langs/sq.po | 101 ++++++++++++++++++++++++++++++++++++ lib.php | 60 +++++++++++++++------- php-mo.php | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 473 insertions(+), 173 deletions(-) create mode 100644 css/center.css create mode 100644 langs/ast.po delete mode 100644 langs/php-mo.php create mode 100644 langs/sq.po create mode 100644 php-mo.php diff --git a/css/center.css b/css/center.css new file mode 100644 index 0000000..987d493 --- /dev/null +++ b/css/center.css @@ -0,0 +1,62 @@ + +/*! mageia.org nav CSS CENTER PART */ + +#lang_form { position:relative;left:0;top:0 } + + +#mgnav { + background: #ffffff; + padding-bottom: 0px; +} + +#nav { + margin: auto; +} + +#nav a.mageia { + width: 112px; + background: #fff url(//nav.mageia.org/css/mageia-logo-nav-3.png) no-repeat 5px 12px; + color: transparent; + text-shadow: none; +} + +.about #mgnav .about, +.downloads #mgnav .downloads, +.community #mgnav .community, +.blog #mgnav .community, +.section-index #mgnav .community, /*forum*/ +.mediawiki #mgnav .wiki, +.support #mgnav .support, +.contribute #mgnav .contribute, +.donate #mgnav .donate, +.bugs-mageia-org #mgnav .contribute, +.contrib #mgnav .contrib, +.you #mgnav .you, +.contact #mgnav .contact, +.doc #mgnav .doc +{ + background: #2383C2; + background: -webkit-linear-gradient(top, #3494D3 0%, #2383C2 50%); + background: -moz-linear-gradient(top, #3494D3 0%, #2383C2 50%); + background: -o-linear-gradient(top, #3494D3 0%, #2383C2 50%); + background: linear-gradient(top, #3494D3 0%, #2383C2 50%); +} + + +#mgnavtitle, /* deprecated */ +#mgnavt /* preferred */ +{ + text-align: center; +} + + +/* allows to have a title + contextual sub menu */ +header#mgnavt { text-align: center; } +#mgnavt ul { font-size: 12px; margin: 0 0 0 2em; padding: 0; display: inline; } +#mgnavt ul li { display: inline; margin: 0 0.3em; padding: 0; } + +/*from all.css*/ +#mgnavsub ul { + margin: auto; + padding: 0px 0px 0px 0px; +} diff --git a/css/index.php b/css/index.php index 66604b2..a7aafd6 100644 --- a/css/index.php +++ b/css/index.php @@ -19,4 +19,16 @@ header('Content-Type: text/css;charset=utf-8'); header(sprintf('Expires: %s', gmdate('r', strtotime('+1 day')))); -echo str_replace('nav.mageia.org', $_SERVER['HTTP_HOST'], file_get_contents('all.css')); + +$style = isset($_GET['s']) ? trim($_GET['s']) : null; + + if ( $style == 'Center' ){ + echo str_replace('nav.mageia.org', $_SERVER['HTTP_HOST'], file_get_contents('source.css')); + echo str_replace('nav.mageia.org', $_SERVER['HTTP_HOST'], file_get_contents('center.css')); + echo "/*if lang_from missing, add some space*/ #nav li:last-child { padding-right:143px }"; + } + else { + echo str_replace('nav.mageia.org', $_SERVER['HTTP_HOST'], file_get_contents('source.css')); + } + + diff --git a/langs/ast.po b/langs/ast.po new file mode 100644 index 0000000..c7d752e --- /dev/null +++ b/langs/ast.po @@ -0,0 +1,101 @@ +# gettext catalog for mognase web page(s) +# Copyright (C) 2014 - 2014 Mageia +# This file is distributed under the same license as +# the content of the corresponding web page(s). +# +# Generated by extract2gettext.php +# Domain: mognase +# +# include translation strings from: +# _nav/lib.php +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: Mageia\n" +"Report-Msgid-Bugs-To: mageia-i18n@mageia.org\n" +"POT-Creation-Date: 2014-03-31 16:22:46+0000\n" +"PO-Revision-Date: 2014-05-07 16:44+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Asturian (http://www.transifex.com/projects/p/mageia/language/ast/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ast\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: "/web/_nav/lib.php +232" +msgid "Go to mageia.org site map." +msgstr "" + +#: "/web/_nav/lib.php +233" +msgid "About us" +msgstr "" + +#: "/web/_nav/lib.php +233" +msgid "Learn more about Mageia." +msgstr "" + +#: "/web/_nav/lib.php +234" +msgid "Downloads" +msgstr "" + +#: "/web/_nav/lib.php +234" +msgid "Download Mageia ISO and updates." +msgstr "" + +#: "/web/_nav/lib.php +235" +msgid "Support" +msgstr "Sofitu" + +#: "/web/_nav/lib.php +235" +msgid "Get support from Mageia community." +msgstr "" + +#: "/web/_nav/lib.php +236" +msgid "Wiki" +msgstr "Wiki" + +#: "/web/_nav/lib.php +236" +msgid "Wiki of the Mageia Community" +msgstr "" + +#: "/web/_nav/lib.php +237" +msgid "Docs" +msgstr "" + +#: "/web/_nav/lib.php +237" +msgid "Documentations of Mageia" +msgstr "" + +#: "/web/_nav/lib.php +238" +msgid "Community" +msgstr "Comunidá" + +#: "/web/_nav/lib.php +239" +msgid "Contribute" +msgstr "Contribuyir" + +#: "/web/_nav/lib.php +239" +msgid "You too can build Mageia with us!" +msgstr "" + +#: "/web/_nav/lib.php +240" +msgid "Donate" +msgstr "" + +#: "/web/_nav/lib.php +241" +msgid "You" +msgstr "" + +#: "/web/_nav/lib.php +241" +msgid "Your Mageia online account." +msgstr "" + +#: "/web/_nav/lib.php +242" +msgid "Contact" +msgstr "" + +#: "/web/_nav/lib.php +242" +msgid "Contact Us" +msgstr "" diff --git a/langs/php-mo.php b/langs/php-mo.php deleted file mode 100644 index 470ce80..0000000 --- a/langs/php-mo.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * NB: - * - If no $output_file specified, output filename is same as $input_file (but .mo) - * - Returns true/false for success/failure - * - No warranty, but if it breaks, please let me know - * - * More info: - * https://github.com/josscrowcroft/php.mo - * - * Based on php-msgfmt by Matthias Bauer (Copyright © 2007), a command-line PHP tool - * for converting .po files to .mo. - * (http://wordpress-soc-2007.googlecode.com/svn/trunk/moeffju/php-msgfmt/msgfmt.php) - * - * License: GPL v3 http://www.opensource.org/licenses/gpl-3.0.html - */ - -function phpmo_clean_helper($x) { - if (is_array($x)) { - foreach ($x as $k => $v) { - $x[$k] = phpmo_clean_helper($v); - } - } else { - if ($x[0] == '"') - $x = substr($x, 1, -1); - $x = str_replace("\"\n\"", '', $x); - $x = str_replace('$', '\\$', $x); - } - return $x; -} - -/* Parse gettext .po files. */ -/* @link http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files */ -function phpmo_parse_po_file($in) { - // read .po file - $fh = @fopen($in, 'r'); - if ($fh === false) { - // Could not open file resource - return false; - } - - // results array - $hash = array (); - // temporary array - $temp = array (); - // state - $state = null; - $fuzzy = false; - - // iterate over lines - while(($line = fgets($fh, 65536)) !== false) { - $line = trim($line); - if ($line === '') { - // save stored entry on empty line - // block moved to fix "fuzzy flag first line" bug which didn't saved previous proper string at all - if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) { - if (!$fuzzy) - $hash[] = $temp; - $temp = array (); - $state = null; - $fuzzy = false; - } - continue; - } - $array_of_splited_string = preg_split('/\s/', $line, 2); - $key = $array_of_splited_string[0]; - $data = (isset($array_of_splited_string[1]) ? $array_of_splited_string[1] : ''); - - switch ($key) { - case '#,' : // flag... - $fuzzy = in_array('fuzzy', preg_split('/,\s*/', $data)); - case '#' : // translator-comments - case '#.' : // extracted-comments - case '#:' : // reference... - case '#|' : // msgid previous-untranslated-string - break; - case '#~' : // commented-unused-string - $temp = array (); - $state = null; - $fuzzy = false; - break; - case 'msgctxt' : - // context - case 'msgid' : - // untranslated-string - case 'msgid_plural' : - // untranslated-string-plural - $state = $key; - $temp[$state] = $data; - break; - case 'msgstr' : - // translated-string - $state = 'msgstr'; - $temp[$state][] = $data; - break; - default : - if (strpos($key, 'msgstr[') !== FALSE) { - // translated-string-case-n - $state = 'msgstr'; - $temp[$state][] = $data; - } else { - // continued lines - switch ($state) { - case 'msgctxt' : - case 'msgid' : - case 'msgid_plural' : - $temp[$state] .= "\n" . $line; - break; - case 'msgstr' : - $temp[$state][sizeof($temp[$state]) - 1] .= "\n" . $line; - break; - default : - // parse error - fclose($fh); - return FALSE; - } - } - break; - } - } - fclose($fh); - - // add final entry - if ($state == 'msgstr') - $hash[] = $temp; - - // Cleanup data, merge multiline entries, reindex hash for ksort - $temp = $hash; - $hash = array (); - foreach ($temp as $entry) { - foreach ($entry as & $v) { - $v = phpmo_clean_helper($v); - if ($v === FALSE) { - // parse error - return FALSE; - } - } - $hash[$entry['msgid']] = $entry; - } - - return $hash; -} - -?> \ No newline at end of file diff --git a/langs/sq.po b/langs/sq.po new file mode 100644 index 0000000..056c8bd --- /dev/null +++ b/langs/sq.po @@ -0,0 +1,101 @@ +# gettext catalog for mognase web page(s) +# Copyright (C) 2014 - 2014 Mageia +# This file is distributed under the same license as +# the content of the corresponding web page(s). +# +# Generated by extract2gettext.php +# Domain: mognase +# +# include translation strings from: +# _nav/lib.php +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: Mageia\n" +"Report-Msgid-Bugs-To: mageia-i18n@mageia.org\n" +"POT-Creation-Date: 2014-03-31 16:22:46+0000\n" +"PO-Revision-Date: 2014-05-07 16:44+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Albanian (http://www.transifex.com/projects/p/mageia/language/sq/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sq\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: "/web/_nav/lib.php +232" +msgid "Go to mageia.org site map." +msgstr "" + +#: "/web/_nav/lib.php +233" +msgid "About us" +msgstr "" + +#: "/web/_nav/lib.php +233" +msgid "Learn more about Mageia." +msgstr "" + +#: "/web/_nav/lib.php +234" +msgid "Downloads" +msgstr "Shkarkime" + +#: "/web/_nav/lib.php +234" +msgid "Download Mageia ISO and updates." +msgstr "" + +#: "/web/_nav/lib.php +235" +msgid "Support" +msgstr "Mbështetje" + +#: "/web/_nav/lib.php +235" +msgid "Get support from Mageia community." +msgstr "" + +#: "/web/_nav/lib.php +236" +msgid "Wiki" +msgstr "Wiki" + +#: "/web/_nav/lib.php +236" +msgid "Wiki of the Mageia Community" +msgstr "" + +#: "/web/_nav/lib.php +237" +msgid "Docs" +msgstr "" + +#: "/web/_nav/lib.php +237" +msgid "Documentations of Mageia" +msgstr "" + +#: "/web/_nav/lib.php +238" +msgid "Community" +msgstr "Komuniteti" + +#: "/web/_nav/lib.php +239" +msgid "Contribute" +msgstr "Kontribuo" + +#: "/web/_nav/lib.php +239" +msgid "You too can build Mageia with us!" +msgstr "" + +#: "/web/_nav/lib.php +240" +msgid "Donate" +msgstr "" + +#: "/web/_nav/lib.php +241" +msgid "You" +msgstr "" + +#: "/web/_nav/lib.php +241" +msgid "Your Mageia online account." +msgstr "" + +#: "/web/_nav/lib.php +242" +msgid "Contact" +msgstr "" + +#: "/web/_nav/lib.php +242" +msgid "Contact Us" +msgstr "" diff --git a/lib.php b/lib.php index 064435c..c3377d3 100644 --- a/lib.php +++ b/lib.php @@ -18,6 +18,41 @@ */ // definition +require_once('php-mo.php'); + +// languages for home +$langs = array( + 'ast' => 'Asturianu', + 'ca' => 'Català', + 'cs' => 'Čeština', + 'de' => 'Deutsch', + 'el' => 'Ελληνικά', + 'en' => 'English', + 'eo' => 'Esperanto', + 'es' => 'Español', + 'et' => 'Eesti', + 'fi' => 'Suomeksi', + 'fr' => 'Français', + 'id' => 'Bahasa Indonesia', + 'it' => 'Italiano', + 'lv' => 'Latviešu', + 'nb' => 'Bokmål', + 'nl' => 'Nederlands', + 'pl' => 'Polski', + 'pt' => 'Português', + 'pt-br' => 'Português do Brasil', + 'ro' => 'Română', + 'ru' => 'Русский', + 'sl' => 'Slovenščina', + 'sq' => 'Gjuha shqipe', + 'sv' => 'Svenska', + 'tr' => 'Türkçe', + 'uk' => 'Українська', + 'ur' => 'اردو', + 'zh-cn' => '简体中文', + 'zh-tw' => '正體中文' +); + class NCache { function __construct() { } @@ -154,7 +189,6 @@ class l10n } if (file_exists($po_file)) { - require_once('langs/php-mo.php'); $dictionary = phpmo_parse_po_file($po_file); foreach ($dictionary as $key => $value) { @@ -282,7 +316,11 @@ function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = 'www. */ function _mgnav_style() { - return ''; + if ( defined('ALIGNMENT') && constant('ALIGNMENT') == 'Center' ){ + return ''; + } else { + return ''; + } } /** @@ -294,22 +332,8 @@ function _lang_check($s = null) return 'en'; } - $supported = array( - 'ast', - 'cs', - 'de', - 'el', 'en', 'eo', 'es', 'et', - 'fi', 'fr', - 'id', 'it', - 'lv', - 'nb', 'nl', - 'pl', 'pt', 'pt-br', - 'ro', 'ru', - 'sl', 'sv', - 'tr', - 'uk', 'ur', - 'zh-cn', 'zh-tw' - ); + global $langs; + $supported = array_keys($langs); if (in_array($s, $supported)) return $s; diff --git a/php-mo.php b/php-mo.php new file mode 100644 index 0000000..470ce80 --- /dev/null +++ b/php-mo.php @@ -0,0 +1,154 @@ + + * + * NB: + * - If no $output_file specified, output filename is same as $input_file (but .mo) + * - Returns true/false for success/failure + * - No warranty, but if it breaks, please let me know + * + * More info: + * https://github.com/josscrowcroft/php.mo + * + * Based on php-msgfmt by Matthias Bauer (Copyright © 2007), a command-line PHP tool + * for converting .po files to .mo. + * (http://wordpress-soc-2007.googlecode.com/svn/trunk/moeffju/php-msgfmt/msgfmt.php) + * + * License: GPL v3 http://www.opensource.org/licenses/gpl-3.0.html + */ + +function phpmo_clean_helper($x) { + if (is_array($x)) { + foreach ($x as $k => $v) { + $x[$k] = phpmo_clean_helper($v); + } + } else { + if ($x[0] == '"') + $x = substr($x, 1, -1); + $x = str_replace("\"\n\"", '', $x); + $x = str_replace('$', '\\$', $x); + } + return $x; +} + +/* Parse gettext .po files. */ +/* @link http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files */ +function phpmo_parse_po_file($in) { + // read .po file + $fh = @fopen($in, 'r'); + if ($fh === false) { + // Could not open file resource + return false; + } + + // results array + $hash = array (); + // temporary array + $temp = array (); + // state + $state = null; + $fuzzy = false; + + // iterate over lines + while(($line = fgets($fh, 65536)) !== false) { + $line = trim($line); + if ($line === '') { + // save stored entry on empty line + // block moved to fix "fuzzy flag first line" bug which didn't saved previous proper string at all + if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) { + if (!$fuzzy) + $hash[] = $temp; + $temp = array (); + $state = null; + $fuzzy = false; + } + continue; + } + $array_of_splited_string = preg_split('/\s/', $line, 2); + $key = $array_of_splited_string[0]; + $data = (isset($array_of_splited_string[1]) ? $array_of_splited_string[1] : ''); + + switch ($key) { + case '#,' : // flag... + $fuzzy = in_array('fuzzy', preg_split('/,\s*/', $data)); + case '#' : // translator-comments + case '#.' : // extracted-comments + case '#:' : // reference... + case '#|' : // msgid previous-untranslated-string + break; + case '#~' : // commented-unused-string + $temp = array (); + $state = null; + $fuzzy = false; + break; + case 'msgctxt' : + // context + case 'msgid' : + // untranslated-string + case 'msgid_plural' : + // untranslated-string-plural + $state = $key; + $temp[$state] = $data; + break; + case 'msgstr' : + // translated-string + $state = 'msgstr'; + $temp[$state][] = $data; + break; + default : + if (strpos($key, 'msgstr[') !== FALSE) { + // translated-string-case-n + $state = 'msgstr'; + $temp[$state][] = $data; + } else { + // continued lines + switch ($state) { + case 'msgctxt' : + case 'msgid' : + case 'msgid_plural' : + $temp[$state] .= "\n" . $line; + break; + case 'msgstr' : + $temp[$state][sizeof($temp[$state]) - 1] .= "\n" . $line; + break; + default : + // parse error + fclose($fh); + return FALSE; + } + } + break; + } + } + fclose($fh); + + // add final entry + if ($state == 'msgstr') + $hash[] = $temp; + + // Cleanup data, merge multiline entries, reindex hash for ksort + $temp = $hash; + $hash = array (); + foreach ($temp as $entry) { + foreach ($entry as & $v) { + $v = phpmo_clean_helper($v); + if ($v === FALSE) { + // parse error + return FALSE; + } + } + $hash[$entry['msgid']] = $entry; + } + + return $hash; +} + +?> \ No newline at end of file -- cgit v1.2.1