Update ulsdata2json.php for cleaner codes handling
Add supplementalData.xml to .gitignore. Tweaks to make CLDR codes usable in ULS.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
|||||||
*.bak
|
*.bak
|
||||||
/node_modules
|
/node_modules
|
||||||
/dist
|
/dist
|
||||||
|
data/supplementalData.xml
|
||||||
|
|||||||
@@ -55,14 +55,16 @@ $parsedLangdb['territories'] = array();
|
|||||||
foreach ( $supplementalData->territoryInfo->territory as $territoryRecord ) {
|
foreach ( $supplementalData->territoryInfo->territory as $territoryRecord ) {
|
||||||
$territoryAtributes = $territoryRecord->attributes();
|
$territoryAtributes = $territoryRecord->attributes();
|
||||||
$territoryCodeAttr = $territoryAtributes['type'];
|
$territoryCodeAttr = $territoryAtributes['type'];
|
||||||
$territoryCode = "$territoryCodeAttr[0]";
|
$territoryCode = (string) $territoryCodeAttr[0];
|
||||||
$parsedLangdb['territories'][$territoryCode] = array();
|
$parsedLangdb['territories'][$territoryCode] = array();
|
||||||
|
|
||||||
foreach ( $territoryRecord->languagePopulation as $languageRecord ) {
|
foreach ( $territoryRecord->languagePopulation as $languageRecord ) {
|
||||||
$languageAttributes = $languageRecord->attributes();
|
$languageAttributes = $languageRecord->attributes();
|
||||||
$languageCodeAttr = $languageAttributes['type'];
|
$languageCodeAttr = $languageAttributes['type'];
|
||||||
$parsedLangdb['territories'][$territoryCode][] = "$languageCodeAttr[0]";
|
// Lower case is a convention for language codes in ULS.
|
||||||
}
|
// '_' is used in CLDR for compound codes and it's replaced with '-' here.
|
||||||
|
$parsedLangdb['territories'][$territoryCode][] =
|
||||||
|
strtr( strtolower( (string) $languageCodeAttr[0] ), '_', '-' ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
print( "Writing JSON langdb...\n" );
|
print( "Writing JSON langdb...\n" );
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user