Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ExtraneousLanguage JSON format, refs #1691, #1561 #1848

Merged
merged 1 commit into from
Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DefaultSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# this file.
##
$GLOBALS['smwgIP'] = dirname( __FILE__ ) . '/';
$GLOBALS['smwgExtraneousLanguageFileDir'] = __DIR__ . '/languages';
$GLOBALS['smwgExtraneousLanguageFileDir'] = __DIR__ . '/languages/i18n';
##

###
Expand Down
4 changes: 3 additions & 1 deletion includes/NamespaceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SMW;

use SMW\ExtraneousLanguage\ExtraneousLanguage;

/**
* @license GNU GPL v2+
* @since 1.9
Expand Down Expand Up @@ -141,7 +143,7 @@ protected function addNamespaceSettings() {
* @var SMWLanguage $smwgContLang
*/
$this->globalVars['wgExtraNamespaces'] = $this->globalVars['smwgContLang']->getNamespaces() + $this->globalVars['wgExtraNamespaces'];
$this->globalVars['wgNamespaceAliases'] = array_flip( $this->globalVars['smwgContLang']->getNamespaces() ) + $this->globalVars['wgNamespaceAliases'];
$this->globalVars['wgNamespaceAliases'] = array_flip( $this->globalVars['smwgContLang']->getNamespaceAliases() ) + $this->globalVars['wgNamespaceAliases'];

// Support subpages only for talk pages by default
$this->globalVars['wgNamespacesWithSubpages'] = $this->globalVars['wgNamespacesWithSubpages'] + array(
Expand Down
42 changes: 37 additions & 5 deletions languages/SMW_Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @ingroup SMWLanguage
* @ingroup Language
*/
abstract class SMWLanguage {
class SMWLanguage {

// the special message arrays ...
protected $m_DatatypeLabels;
Expand Down Expand Up @@ -137,16 +137,17 @@ abstract class SMWLanguage {
public function __construct() {
// `$this->m_SpecialProperties' is set in descendants.
// Let us initialize reverse mapping.
foreach ( $this->m_SpecialProperties as $propId => $propName ) {
$this->m_SpecialPropertyIds[$propName] = $propId;
}
// foreach ( $this->m_SpecialProperties as $propId => $propName ) {
// $this->m_SpecialPropertyIds[$propName] = $propId;
// }
}


/**
* Function that returns an array of namespace identifiers.
*/
function getNamespaces() {
return $this->m_Namespaces;
global $smwgHistoricTypeNamespace;
$namespaces = $this->m_Namespaces;
if ( !$smwgHistoricTypeNamespace ) {
Expand All @@ -160,6 +161,7 @@ function getNamespaces() {
* Function that returns an array of namespace aliases, if any.
*/
function getNamespaceAliases() {
return $this->m_NamespaceAliases;
global $smwgHistoricTypeNamespace;

$namespaceAliases = $this->m_NamespaceAliases;
Expand Down Expand Up @@ -197,6 +199,7 @@ function getCanonicalDatatypeLabels() {
* should also have a primary label defined in m_DatatypeLabels.
*/
function getDatatypeAliases() {
return $this->m_DatatypeAliases;
return $this->m_useEnDefaultAliases ?
$this->m_DatatypeAliases + self::$enDatatypeAliases :
$this->m_DatatypeAliases;
Expand All @@ -222,6 +225,10 @@ function getCanonicalPropertyLabels() {
*/
function getPropertyAliases() {
return $this->m_SpecialPropertyAliases;

// return $this->m_useEnDefaultAliases ?
// $this->m_SpecialPropertyAliases + self::$enPropertyAliases :
// $this->m_SpecialPropertyAliases;
}

/**
Expand Down Expand Up @@ -277,6 +284,31 @@ function getMonthLabel( $number ) {
return ( ( $number >= 1 ) && ( $number <= 12 ) ) ? $this->m_months[(int)( $number - 1 )] : '';
}

}
function getMonths() {
return $this->m_months;
}

function getMonthsShort() {
return $this->m_monthsshort;
}

public function getTargetFileFor( $languageCode ) {
return __DIR__ . '/i18n/' . $languageCode . '.json';
}

public function getLanguageFor( $languageCode ) {

$contLangFile = 'SMW_Language' . str_replace( '-', '_', ucfirst( $languageCode ) );
$contLangClass = 'SMWLanguage' . str_replace( '-', '_', ucfirst( $languageCode ) );

$file = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, __DIR__ . '/' . $contLangFile . '.php' );

if ( file_exists( $file ) ) {
require_once ( $file );
return new $contLangClass;
}

}


}
182 changes: 182 additions & 0 deletions languages/i18n/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"@metadata": {
"authors": []
},
"fallbackLanguage": "en",
"dataTypeLabels": {
"_wpg": "الصفحة",
"_txt": "نص",
"_cod": "كود",
"_boo": "منطقي",
"_num": "عدد",
"_geo": "الإحداثيات الجغرافية",
"_tem": "الحرارة",
"_dat": "التاريخ",
"_ema": "البريد الإلكتروني",
"_uri": "مسار",
"_anu": "التعليق علي معرف الموارد الموحد",
"_tel": "رقم الهاتف",
"_rec": "تسجيل",
"_qty": "Quantity",
"_mlt_rec": "Monolingual text",
"_eid": "External identifier",
"_ref_rec": "Reference"
},
"dataTypeAliases": {
"URI": "_uri",
"Float": "_num",
"Integer": "_num",
"سلسلة": "_txt",
"Enumeration": "_txt"
},
"propertyLabels": {
"_TYPE": "لديه نوع",
"_URI": "معرف الموارد الموحد معادلة",
"_SUBP": "الخاصية الفرعية ل",
"_SUBC": "تصنيف فرعي من",
"_UNIT": "عرض الوحدات",
"_IMPO": "المستوردة من",
"_CONV": "يقابل",
"_SERV": "يوفر الخدمة",
"_PVAL": "يسمح بالقيمة",
"_MDAT": "تاريخ التعديل",
"_CDAT": "Creation date",
"_NEWP": "Is a new page",
"_LEDT": "Last editor is",
"_ERRP": "يمتلك قيمة غير صحيحة ل",
"_LIST": "يمتلك حقول",
"_SOBJ": "Has subobject",
"_ASK": "Has query",
"_ASKST": "Query string",
"_ASKFO": "Query format",
"_ASKSI": "Query size",
"_ASKDE": "Query depth",
"_ASKDU": "Query duration",
"_MEDIA": "Media type",
"_MIME": "MIME type",
"_ERRC": "Has processing error",
"_ERRT": "Has processing error text",
"_PREC": "Display precision of",
"_LCODE": "Language code",
"_TEXT": "Text",
"_PDESC": "Has property description",
"_PVAP": "Allows pattern",
"_DTITLE": "Display title of",
"_PVUC": "Has uniqueness constraint",
"_PEID": "External identifier",
"_PEFU": "External formatter uri"
},
"propertyAliases": {
"عرض الوحدة": "_UNIT"
},
"dateFormatsByPrecision": {
"SMW_PREC_Y": "Y",
"SMW_PREC_YM": "F Y",
"SMW_PREC_YMD": "F j, Y",
"SMW_PREC_YMDT": "H:i:s, j F Y"
},
"namespaces": {
"SMW_NS_PROPERTY": "خاصية",
"SMW_NS_PROPERTY_TALK": "نقاش_الخاصية",
"SMW_NS_TYPE": "نوع",
"SMW_NS_TYPE_TALK": "نقاش_النوع",
"SMW_NS_CONCEPT": "مبدأ",
"SMW_NS_CONCEPT_TALK": "نقاش_المبدأ"
},
"namespaceAliases": [],
"dateFormats": [
[
"SMW_Y"
],
[
"SMW_MY",
"SMW_YM"
],
[
"SMW_MDY",
"SMW_DMY",
"SMW_YMD",
"SMW_YDM"
]
],
"months": [
[
"يناير",
"يناير"
],
[
"فبراير",
"فبراير"
],
[
"مارس",
"مارس"
],
[
"أبريل",
"أبريل"
],
[
"مايو",
"مايو"
],
[
"يونيو",
"يونيو"
],
[
"يوليو",
"يوليو"
],
[
"أغسطس",
"أغسطس"
],
[
"سبتمبر",
"سبتمبر"
],
[
"أكتوبر",
"أكتوبر"
],
[
"نوفمبر",
"نوفمبر"
],
[
"ديسمبر",
"ديسمبر"
]
],
"days": [
[
"Monday",
"Mon"
],
[
"Tuesday",
"Tue"
],
[
"Wednesday",
"Wed"
],
[
"Thursday",
"Thu"
],
[
"Friday",
"Fri"
],
[
"Saturday",
"Sat"
],
[
"Sunday",
"Sun"
]
]
}