Commit 8f13111b by pupi1985 Committed by Scott

Added metadata to the translations

parent 86d7c84f
...@@ -66,7 +66,11 @@ ...@@ -66,7 +66,11 @@
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$codetolanguage=array( // 2-letter language codes as per ISO 639-1 /*
* @deprecated The hardcoded language ids will be removed in favor of language metadata files.
* See qa-lang/en-GB directory for a clear example of how to use them.
*/
$codetolanguage = array( // 2-letter language codes as per ISO 639-1
'ar' => 'Arabic - العربية', 'ar' => 'Arabic - العربية',
'az' => 'Azerbaijani - Azərbaycanca', 'az' => 'Azerbaijani - Azərbaycanca',
'bg' => 'Bulgarian - Български', 'bg' => 'Bulgarian - Български',
...@@ -117,17 +121,24 @@ ...@@ -117,17 +121,24 @@
'zh' => 'Chinese Simplified - 简体中文', 'zh' => 'Chinese Simplified - 简体中文',
); );
$options=array('' => 'English (US)'); $options = array('' => 'English (US)');
$directory=@opendir(QA_LANG_DIR); $directory = @opendir(QA_LANG_DIR);
if (is_resource($directory)) { if (is_resource($directory)) {
while (($code=readdir($directory))!==false) while (($code = readdir($directory)) !== false) {
if (is_dir(QA_LANG_DIR.$code) && isset($codetolanguage[$code])) if (is_dir(QA_LANG_DIR . $code) && isset($codetolanguage[$code]))
$options[$code]=$codetolanguage[$code]; $options[$code] = $codetolanguage[$code];
}
closedir($directory); closedir($directory);
} }
foreach (glob(QA_LANG_DIR . '*/qa-lang-metadata.php') as $filename) {
$code = basename(dirname($filename));
$metadata = include QA_LANG_DIR . $code . '/qa-lang-metadata.php';
if (isset($metadata['display_name']))
$options[$code] = $metadata['display_name'];
}
asort($options, SORT_STRING); asort($options, SORT_STRING);
return $options; return $options;
......
<?php
/*
Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/
File: qa-lang/en-GB/qa-lang-metadata.php
Version: See define()s at top of qa-include/qa-base.php
Description: Contains metadata about the translations
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
return array(
'display_name' => 'English (UK)',
);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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