[Dojo-checkins] peller - r15204 - util/trunk/buildscripts/cldr
dojo-checkins-admin at dojotoolkit.org
dojo-checkins-admin at dojotoolkit.org
Wed Sep 10 18:49:32 UTC 2008
Author: peller
Date: Wed Sep 10 11:49:25 2008
New Revision: 15204
Modified:
util/trunk/buildscripts/cldr/alias.js
util/trunk/buildscripts/cldr/arrayInherit.js
util/trunk/buildscripts/cldr/calendar.xsl
util/trunk/buildscripts/cldr/specialLocale.js
Log:
Another stab at chasing XML aliases. Seems to preserve the abbreviated variants this time. Refs #7607. Thanks, Evan.
Modified: util/trunk/buildscripts/cldr/alias.js
==============================================================================
--- util/trunk/buildscripts/cldr/alias.js (original)
+++ util/trunk/buildscripts/cldr/alias.js Wed Sep 10 11:49:25 2008
@@ -27,8 +27,11 @@
var BUNDLES = ['gregorian'];
var LOCALE_ALIAS_MARK = '@localeAlias';
+var LOCALE_ALIAS_SOURCE_PROPERTY = 'source';
var LOCALE_ALIAS_TARGET_PROPERTY = 'target';
var LOCALE_ALIAS_TARGET_BUNDLE = 'bundle';
+var localeAliasPaths = [];/**/
+var records = {};/*{property : boolean}, record whether a property has been calculated for alias path*/
var updated = false;
print('alias.js...');
@@ -42,7 +45,6 @@
var jsFilePath = jsFileName.split("/");
var locale = jsFilePath[jsFilePath.length-2];
if(locale=="nls"){continue;} // no need for root bundle
-
try{
dojo.i18n._requireLocalization('dojo.cldr', BUNDLES[i], locale); //declare bundle
var bundle = dojo.i18n.getLocalization('dojo.cldr', BUNDLES[i], locale); //get bundle
@@ -52,46 +54,82 @@
if(!bundle) continue;
updated = false;
- logStr += locale + ":" + BUNDLES[i] + "=========================================================================\n";
- for(p in bundle){
- if(p.indexOf(LOCALE_ALIAS_MARK) >= 0){
- //p like 'xxx at localeAlias'
- _processLocaleAlias(bundle, p, nativeSrcBundle);
- }
- }
+ //logStr += locale + ":" + BUNDLES[i] + "=========================================================================\n";
+
+ _calculateAliasPath(bundle);
+ //logStr += "all alias paths=" + dojo.toJson(localeAliasPaths) + "\n";
+
+ _processLocaleAlias(localeAliasPaths, bundle, nativeSrcBundle);
if(updated){
fileUtil.saveUtf8File(jsFileName, "(" + dojo.toJson(nativeSrcBundle, true) + ")");
}
- logStr += '\n';
+ //logStr += '\n';
}
+ cleanLocaleAlias(fileList);
}
-fileUtil.saveUtf8File(logDir + '/alias.log',logStr+'\n');
-print('CLDR finished, please refer to logs at ' + logDir + ' for more details.');
+//fileUtil.saveUtf8File(logDir + '/alias.log',logStr+'\n');
+//print('CLDR finished, please refer to logs at ' + logDir + ' for more details.');
+
-function _processLocaleAlias(bundle/*JSON Obj*/, localeAliasKey/*String*/,nativeSrcBundle/*JSON Obj*/){
+function _calculateAliasPath(bundle){
+ for(p in bundle){
+ var index = p.indexOf(LOCALE_ALIAS_MARK);
+ if(index >= 0 /*p like 'xxx at localeAlias6'*/){
+ var localeAliasSource/*String*/ = p.substring(0,index);
+ if(records[localeAliasSource]/*calculated*/){
+ //logStr += p + " has been calculated, ignored\n"
+ continue;
+ }
+
+ var path = [];
+ var aliasIndex = new Number(p.substring(index + LOCALE_ALIAS_MARK.length));
+ //logStr += "aliasIndex for " + p + " is " + aliasIndex + "\n";
+ var i = aliasIndex;
+ while(bundle[localeAliasSource + LOCALE_ALIAS_MARK + (--i)]){}
+
+ var src = localeAliasSource;
+ while(bundle[localeAliasSource + LOCALE_ALIAS_MARK + (++i)]){
+ var mapping = {};
+ mapping[LOCALE_ALIAS_SOURCE_PROPERTY] = src;
+ mapping[LOCALE_ALIAS_TARGET_PROPERTY] = bundle[localeAliasSource + LOCALE_ALIAS_MARK + i][LOCALE_ALIAS_TARGET_PROPERTY];
+ mapping[LOCALE_ALIAS_TARGET_BUNDLE] = bundle[localeAliasSource + LOCALE_ALIAS_MARK + i][LOCALE_ALIAS_TARGET_BUNDLE];
+ path.push(mapping);
+ records[src] = true;
+ src = bundle[localeAliasSource + LOCALE_ALIAS_MARK + i][LOCALE_ALIAS_TARGET_PROPERTY];
+ }
+ path = path.reverse();
+ //logStr += "alias path calucated for " + localeAliasSource + "=" + dojo.toJson(path) + "\n";
+ localeAliasPaths.push(path);
+ }
+ }
+}
+
+function _processLocaleAlias(localeAliasPaths/*Array*/, bundle/*JSON Obj*/, nativeSrcBundle/*JSON Obj*/){
//Summary: Update all properties as defined by 'locale' alias mapping
- // E.g.'months-format-abbr at localeAlias':{'target':"months-format-wide", 'bundle':"gregorian"},
+ // E.g.'months-format-abbr at localeAlias6':{'target':"months-format-wide", 'bundle':"gregorian"},
// means the array values of 'months-format-abbr' in current bundle should be
// merged with(inherit or overwrite) that of 'months-format-wide' in 'gregorian' bundle
//
//Note: Currently no bundle recognition, always assume 'gregorian'.
-
- var index = localeAliasKey.indexOf(LOCALE_ALIAS_MARK);
- var localeAliasSource/*String*/ = localeAliasKey.substring(0,index);//e.g 'months-format-abbr at localeAlias' -> 'months-format-abbr'
- var localeAliasTarget/*String*/ = bundle[localeAliasKey][LOCALE_ALIAS_TARGET_PROPERTY];
- //var localeAliasBundle/*String*/ = bundle[localeAliasKey][LOCALE_ALIAS_TARGET_BUNDLE]; //For future use
-
- for(x in bundle){
- if(x.indexOf(LOCALE_ALIAS_MARK) < 0 /*not a locale alias mapping item*/
- && x.indexOf(localeAliasSource) == 0/*x naming start with localeAliasSource*/){
- if(x == localeAliasSource){
- //exactaly match, like 'months-format-abbr at localeAlias':{'target':"months-format-wide",'bundle':"gregorian"},
+ var processed = {};
+ for(var i = 0; i < localeAliasPaths.length; i++){
+ var path = localeAliasPaths[i];
+ for(var j = 0; j < path.length; j++){
+ var mapping = path[j];
+ if(mapping[LOCALE_ALIAS_SOURCE_PROPERTY] != mapping[LOCALE_ALIAS_TARGET_PROPERTY]
+ && bundle[mapping[LOCALE_ALIAS_TARGET_PROPERTY]]/*target existed*/){
+ //e.g. {'source':'months-format-abbr','target':"months-format-wide",'bundle':"gregorian"},
//currently source and target bundles are the same - gregorian
- _updateLocaleAlias(bundle, x, bundle, localeAliasTarget, nativeSrcBundle);
+ if(processed[mapping[LOCALE_ALIAS_SOURCE_PROPERTY]]){/*haven't been processed*/
+ //logStr += "!" + mapping[LOCALE_ALIAS_SOURCE_PROPERTY] +" has been processed for alias, escaped\n";
+ continue;
+ }
+ _updateLocaleAlias(bundle, mapping[LOCALE_ALIAS_SOURCE_PROPERTY], bundle,
+ mapping[LOCALE_ALIAS_TARGET_PROPERTY], nativeSrcBundle);
+ processed[mapping[LOCALE_ALIAS_SOURCE_PROPERTY]] = true;
}else{
- //x naming start with localeAliasSource
//TODO: for future use,
//E.g. in 'buddhist' bundle - 'months at localeAlias':{'target':"months", 'bundle':"gregorian"}
//this means in 'buddhist',all properties naming start with 'months'
@@ -108,31 +146,57 @@
if(!nativeSrcBundle[aliasSource] && nativeSrcBundle[aliasTarget]//no this property in current locale
&& !compare(sourceBundle[aliasSource], targetBundle[aliasTarget])){
// then should inherit from alias target (as defined by 'locale' alias)
- logStr += '1 '+aliasSource + "=" + sourceBundle[aliasSource] + " is replaced with " + aliasTarget + "=" + targetBundle[aliasTarget]+'\n';
+ //logStr += '1 '+aliasSource + "=" + sourceBundle[aliasSource] + " is replaced with " + aliasTarget + "=" + targetBundle[aliasTarget]+'\n';
//sourceBundle[aliasSource] = targetBundle[aliasTarget];
nativeSrcBundle[aliasSource] = targetBundle[aliasTarget];
+ sourceBundle[aliasSource] = nativeSrcBundle[aliasSource];
updated = true;
}else if(nativeSrcBundle[aliasSource] && dojo.isArray(sourceBundle[aliasSource])
&& dojo.isArray(targetBundle[aliasTarget])){
if(sourceBundle[aliasSource].length > targetBundle[aliasTarget].length){
- logStr +="Error:" + aliasSource + ".length > " + aliasTarget + ".length \n";
+ //logStr +="Error:" + aliasSource + ".length > " + aliasTarget + ".length \n";
}
//array property, see if need inherit
for(var i = 0; i < sourceBundle[aliasSource].length; i++){
if(sourceBundle[aliasSource][i] == undefined){//need inherit
- logStr += '2 ' + aliasSource + "["+i+"]=" +sourceBundle[aliasSource][i]+" is replaced with " + aliasTarget+"["+i+"]="+targetBundle[aliasTarget][i]+'\n';
+ //logStr += '2 ' + aliasSource + "["+i+"]=" +sourceBundle[aliasSource][i]+" is replaced with " + aliasTarget+"["+i+"]="+targetBundle[aliasTarget][i]+'\n';
sourceBundle[aliasSource][i] = targetBundle[aliasTarget][i];
updated = true;
}// otherwise no change and use current value
}
if(sourceBundle[aliasSource].length < targetBundle[aliasTarget].length){
- logStr +='3 ' + aliasSource +' from ' + sourceBundle[aliasSource].length +' to '
- + (targetBundle[aliasTarget].length-1) + ' are copied from '
- +aliasTarget + '='+ targetBundle[aliasTarget] +'\n';
+ //logStr +='3 ' + aliasSource +' from ' + sourceBundle[aliasSource].length +' to '
+ // + (targetBundle[aliasTarget].length-1) + ' are copied from '
+ // +aliasTarget + '='+ targetBundle[aliasTarget] +'\n';
sourceBundle[aliasSource] = sourceBundle[aliasSource].concat(
targetBundle[aliasTarget].slice(sourceBundle[aliasSource].length));
updated = true;
}
- if(updated) nativeSrcBundle[aliasSource] = sourceBundle[aliasSource];
+ if(updated){
+ nativeSrcBundle[aliasSource] = sourceBundle[aliasSource];
+ }
+ }
+}
+
+function cleanLocaleAlias(fileList/*Array*/){
+ for(var i = 0; i < fileList.length; i++){
+ var fileName = new String(fileList[i]); //Java String
+ try{
+ var bundle = getNativeBundle(fileName);//bundle not flattened
+ }catch(e){print(e);/* simply ignore if no bundle found*/}
+
+ var newBundle = {};
+ var needUpdate = false;
+ for(p in bundle){
+ if(p.indexOf(LOCALE_ALIAS_MARK) < 0){
+ newBundle[p] = bundle[p];
+ }else{
+ needUpdate = true;
+ }
}
+ if(needUpdate){
+ fileUtil.saveUtf8File(fileName, "(" + dojo.toJson(newBundle, true) + ")");
+ //logStr += "cleaned @localAlias for " + fileName + "\n";
+ }
+ }
}
Modified: util/trunk/buildscripts/cldr/arrayInherit.js
==============================================================================
--- util/trunk/buildscripts/cldr/arrayInherit.js (original)
+++ util/trunk/buildscripts/cldr/arrayInherit.js Wed Sep 10 11:49:25 2008
@@ -88,12 +88,12 @@
data = variantData;
}else{
isComplete = true;
- logStr += locale + "===============================================\n";
+ //logStr += locale + "===============================================\n";
for(prop in data){
if(dojo.isArray(data[prop])){
//ignore if the property is an alias source, for alias.js and specialLocale.js
if(isLocaleAliasSrc(prop, bundle)){
- logStr += prop + " is alias, ignored\n";
+ //logStr += prop + " is alias, ignored\n";
continue;
}
@@ -101,7 +101,7 @@
dojo.forEach(data[prop], function(element, index, list){
if(element === undefined && dojo.isArray(variantArray)){
list[index] = variantArray[index];
- logStr += prop + "[" + index + "] undefined, is replaced with " + list[index] + "\n";
+ //logStr += prop + "[" + index + "] undefined, is replaced with " + list[index] + "\n";
hasChanged = true;
if(!("index" in list)){
isComplete = false;
@@ -114,7 +114,7 @@
}
}
}
- logStr += "\n";
+ //logStr += "\n";
}
return isComplete;
});
@@ -123,4 +123,4 @@
}
}
-fileUtil.saveUtf8File(logDir + '/arrayInherit.log',logStr+'\n');
\ No newline at end of file
+//fileUtil.saveUtf8File(logDir + '/arrayInherit.log',logStr+'\n');
\ No newline at end of file
Modified: util/trunk/buildscripts/cldr/calendar.xsl
==============================================================================
--- util/trunk/buildscripts/cldr/calendar.xsl (original)
+++ util/trunk/buildscripts/cldr/calendar.xsl Wed Sep 10 11:49:25 2008
@@ -6,6 +6,7 @@
it seems listing only the parent node doesn't work -->
<xsl:preserve-space elements="month day quarter am pm era pattern dateFormatItem appendItem displayName"/>
<xsl:strip-space elements="*"/>
+<xsl:variable name="index" select="number(1)" saxon:assignable="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
@@ -59,6 +60,14 @@
<xsl:template name="calendar" match="calendar">
<!-- will be overridden with 'true' if from 'locale' alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">*</xsl:with-param>
+ <xsl:with-param name="bundle" select="@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ <!-- insert 'locale' alias information start -->
<xsl:choose>
<xsl:when test="count(./alias)>0">
<!-- Handle Alias -->
@@ -71,16 +80,6 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">*</xsl:with-param>
- <xsl:with-param name="bundle" select="@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information start -->
-
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
@@ -93,6 +92,46 @@
<xsl:param name="ctx" select="../@type"/>
<!-- will be overridden with 'true' if from 'locale' alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <xsl:variable name="item" select="substring-before(name(), 'Width')"/>
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:if test="name()='months' or name()='days' or name()='quarters'">
+ <xsl:call-template name="insert_alias_info"/>
+ </xsl:if>
+ <xsl:if test="name()='monthWidth' or name()='dayWidth' or name()='quarterWidth'">
+ <!-- e.g. for <monthContext type="format">
+ <monthWidth type="abbreviated">
+ <alias source="locale" path="../monthWidth[@type='wide']"/>
+ </monthWidth>
+ ......
+ alias info will be recorded as 'months-format-abbr at localeAlias' : {'target' : "months-format-wide"}
+ TBD: Seems the following section cann't be extracted out as a reusable template
+ insert 'locale' alias information end -->
+ <xsl:call-template name="insert_comma"/>
+ '<xsl:value-of select="$item"/><xsl:text>s-</xsl:text>
+ <xsl:call-template name="camel_case">
+ <xsl:with-param name="name"><xsl:value-of select="$ctx"></xsl:value-of></xsl:with-param>
+ </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="$width='abbreviated'"><xsl:text>-abbr</xsl:text></xsl:when>
+ <xsl:otherwise><xsl:value-of select="concat('-',$width)"></xsl:value-of></xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>@localeAlias</xsl:text>
+ <xsl:value-of select="$index"/><saxon:assign name="index" select="sum($index + 1)"/>
+ <xsl:text>':{'target':"</xsl:text><xsl:value-of select="$item"/><xsl:text>s-</xsl:text>
+ <xsl:call-template name="camel_case">
+ <xsl:with-param name="name"><xsl:value-of select="../@type"/></xsl:with-param>
+ </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="@type='abbreviated'"><xsl:text>-abbr</xsl:text></xsl:when>
+ <xsl:otherwise><xsl:value-of select="concat('-', at type)"/></xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>",'bundle':"</xsl:text><xsl:value-of select="../../../@type"/><xsl:text>"}</xsl:text>
+ </xsl:if>
+ </xsl:if>
+ <!-- insert 'locale' alias information end -->
+
<xsl:choose>
<xsl:when test="count(./alias)>0">
<!-- Handle Alias -->
@@ -111,19 +150,12 @@
<xsl:if test="name()='months' or name()='monthContext'
or name()='days' or name()='dayContext'
or name()='quarters' or name()='quarterContext'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias and (name()='months' or name()='days' or name()='quarters')">
- <xsl:call-template name="insert_alias_info"/>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select="*">
<xsl:call-template name="months_days_quarters"></xsl:call-template>
</xsl:for-each>
</xsl:if>
<xsl:if test="name()='monthWidth' or name()='dayWidth' or name()='quarterWidth'">
- <xsl:variable name="item" select="substring-before(name(), 'Width')"/>
+ <!--xsl:variable name="item" select="substring-before(name(), 'Width')"/-->
<xsl:if test="count(*[not(@draft)])>0 or count(*[@draft!='provisional' and @draft!='unconfirmed'])>0">
<xsl:call-template name="insert_comma"/>
'<xsl:value-of select="$item"/>
@@ -140,48 +172,9 @@
<xsl:text>':</xsl:text>
<!--xsl:call-template name="subSelect"><xsl:with-param name="name" select="./*[name()=$item]"></xsl:with-param></xsl:call-template-->
<xsl:call-template name="subSelect_in_place"><xsl:with-param name="name" select="$item"></xsl:with-param></xsl:call-template>
-
- <!-- insert 'locale' alias information start
- e.g. for <monthContext type="format">
- <monthWidth type="abbreviated">
- <alias source="locale" path="../monthWidth[@type='wide']"/>
- </monthWidth>
- ......
- alias info will be recorded as 'months-format-abbr at localeAlias' : {'target' : "months-format-wide"}
- TBD: Seems the following section cann't be extracted out as a reusable template
- insert 'locale' alias information end -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_comma"/>
- '<xsl:value-of select="$item"/><xsl:text>s-</xsl:text>
- <xsl:call-template name="camel_case">
- <xsl:with-param name="name"><xsl:value-of select="$ctx"></xsl:value-of></xsl:with-param>
- </xsl:call-template>
- <xsl:choose>
- <xsl:when test="$width='abbreviated'"><xsl:text>-abbr</xsl:text></xsl:when>
- <xsl:otherwise><xsl:value-of select="concat('-',$width)"></xsl:value-of></xsl:otherwise>
- </xsl:choose>
- <xsl:text>@localeAlias':{'target':"</xsl:text><xsl:value-of select="$item"/><xsl:text>s-</xsl:text>
- <xsl:call-template name="camel_case">
- <xsl:with-param name="name"><xsl:value-of select="../@type"/></xsl:with-param>
- </xsl:call-template>
- <xsl:choose>
- <xsl:when test="@type='abbreviated'"><xsl:text>-abbr</xsl:text></xsl:when>
- <xsl:otherwise><xsl:value-of select="concat('-', at type)"/></xsl:otherwise>
- </xsl:choose>
- <xsl:text>",'bundle':"</xsl:text><xsl:value-of select="../../../@type"/><xsl:text>"}</xsl:text>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
</xsl:if>
</xsl:if>
- <!--xsl:if test="name()='quarterWidth'">
- <xsl:if test="count(*[not(@draft)])>0 or count(*[@draft!='provisional' and @draft!='unconfirmed'])>0">
- <xsl:call-template name="insert_comma"/>
- 'quarters-<xsl:value-of select="concat($ctx,'-',$width)"></xsl:value-of> <xsl:text>':</xsl:text>
- <xsl:call-template name="subSelect_in_place"><xsl:with-param name="name" select="'quarter'"></xsl:with-param></xsl:call-template>
- </xsl:if>
- </xsl:if-->
- </xsl:otherwise>
+ </xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -193,16 +186,17 @@
......
alias info will be recorded as 'months at localeAlias' : {'target':"months", 'bundle' : 'gregorian'} -->
<xsl:template name="insert_alias_info">
- <!-- alias source node name-->
- <xsl:param name="sourceName" select="name()"></xsl:param>
- <!-- alias target node name, same as source node by default-->
- <xsl:param name="targetName" select="$sourceName"></xsl:param>
- <!-- alias target bundle-->
- <xsl:param name="bundle" select="../@type"></xsl:param>
- <xsl:call-template name="insert_comma"/>
- '<xsl:value-of select="$sourceName"/><xsl:text>@localeAlias':{'target':"</xsl:text><xsl:value-of select="$targetName"/><xsl:text>", 'bundle':"</xsl:text>
- <xsl:value-of select="$bundle"/><xsl:text>"}</xsl:text>
- <!--xsl:value-of select="../@type"/><xsl:text>"}</xsl:text-->
+ <!-- alias source node name-->
+ <xsl:param name="sourceName" select="name()"></xsl:param>
+ <!-- alias target node name, same as source node by default-->
+ <xsl:param name="targetName" select="$sourceName"></xsl:param>
+ <!-- alias target bundle-->
+ <xsl:param name="bundle" select="../@type"></xsl:param>
+ <xsl:call-template name="insert_comma"/>
+ '<xsl:value-of select="$sourceName"/><xsl:text>@localeAlias</xsl:text>
+ <xsl:value-of select="$index"/><saxon:assign name="index" select="sum($index + 1)"/>
+ <xsl:text>':{'target':"</xsl:text><xsl:value-of select="$targetName"/><xsl:text>", 'bundle':"</xsl:text>
+ <xsl:value-of select="$bundle"/><xsl:text>"}</xsl:text>
</xsl:template>
@@ -210,6 +204,13 @@
<xsl:template name="apm" match="am|pm">
<!-- will be overridden with 'true' if from 'locale' alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:call-template name="insert_alias_info"/>
+ </xsl:if>
+ <!-- insert 'locale' alias information end -->
+
<xsl:choose>
<xsl:when test="alias">
<!-- Handle Alias -->
@@ -224,22 +225,9 @@
<xsl:otherwise>
<xsl:if test="not(@draft) or @draft!='provisional' and @draft!='unconfirmed'">
<xsl:call-template name="insert_comma"/>
- '<xsl:value-of select="name()"/>
- <!--
- <xsl:if test="name()='am'">
- 'am</xsl:if>
- <xsl:if test="name()='pm'">
- 'pm</xsl:if>
- -->
+ '<xsl:value-of select="name()"/>
<xsl:text>':"</xsl:text>
<xsl:value-of select="replace(.,'"', '\\"')"/><xsl:text>"</xsl:text>
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info"/>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
</xsl:if>
</xsl:otherwise>
</xsl:choose>
@@ -248,8 +236,28 @@
<!-- process eras -->
<xsl:template match="eras" name="eras">
<xsl:param name="name" select="name()"></xsl:param>
- <!-- will be overridden with 'true' if from alias, see 'invoke_template_by_name' -->
- <xsl:param name="fromLocaleAlias" select="false()"/>
+ <!-- will be overridden with 'true' if from alias, see 'invoke_template_by_name' -->
+ <xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:choose>
+ <xsl:when test="name()='eras'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">era</xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName" select="$name"></xsl:with-param>
+ <xsl:with-param name="targetName" select="name()"></xsl:with-param>
+ <xsl:with-param name="bundle" select="../../@type"></xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <!-- insert 'locale' alias information end -->
+
<xsl:choose>
<xsl:when test="count(./alias)>0">
<!-- Handle Alias -->
@@ -265,31 +273,11 @@
<xsl:otherwise>
<xsl:choose>
<xsl:when test="name()='eras'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">era</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select="*">
<xsl:call-template name="eras"></xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName" select="$name"></xsl:with-param>
- <xsl:with-param name="targetName" select="name()"></xsl:with-param>
- <xsl:with-param name="bundle" select="../../@type"></xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select=".">
<xsl:if test="count(*[not(@draft)])>0
or count(*[@draft!='provisional' and @draft!='unconfirmed'])>0">
@@ -317,12 +305,31 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
+
+
<!-- process dateFormat & timeFormat -->
<xsl:template match="dateFormats | timeFormats" name="date_time_Formats">
<xsl:param name="width" select="@type"></xsl:param>
<!-- will be overridden with 'true' if from alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:if test="name()='dateFormats' or name()='timeFormats'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName" select="substring-before(name(), 's')"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="name()!='default' and (name()='dateFormatLength' or name()='timeFormatLength')">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName" select="concat(substring-before(name(), 'Length'), '-', $width)"/>
+ <xsl:with-param name="targetName" select="concat(substring-before(name(), 'Length'), '-', @type)"/>
+ <xsl:with-param name="bundle" select="../../@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ <!-- insert 'locale' alias information end -->
+
<xsl:choose>
<xsl:when test="count(./alias)>0">
<!-- Handle Alias -->
@@ -338,32 +345,12 @@
<xsl:otherwise>
<xsl:choose>
<xsl:when test="name()='dateFormats' or name()='timeFormats'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName" select="substring-before(name(), 's')"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select="*">
<xsl:call-template name="date_time_Formats"></xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:if test="name()!='default'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias and (name()='dateFormatLength' or name()='timeFormatLength') ">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName" select="concat(substring-before(name(), 'Length'), '-', $width)"/>
- <xsl:with-param name="targetName" select="concat(substring-before(name(), 'Length'), '-', @type)"/>
- <xsl:with-param name="bundle" select="../../@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select=".//pattern[not(@draft)] |
.//pattern[@draft!='provisional' and @draft!='unconfirmed']">
<xsl:call-template name="insert_comma"/>
@@ -384,6 +371,35 @@
<xsl:param name="width" select="@type"></xsl:param>
<!-- will be overridden with 'true' if from alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:if test="name()='dateTimeFormats'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">dateTime</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="name()='dateTimeFormatLength'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">dateTimeFormat</xsl:with-param>
+ <xsl:with-param name="bundle" select="../../@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="name()='availableFormats'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">dateTimeAvailableFormats</xsl:with-param>
+ <xsl:with-param name="bundle" select="../../@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="name()='appendItems'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">dateTimeFormats-appendItem-</xsl:with-param>
+ <xsl:with-param name="bundle" select="../../@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ <!-- insert 'locale' alias information start -->
+
<xsl:choose>
<xsl:when test="./alias">
<!-- Handle Alias -->
@@ -399,15 +415,6 @@
<xsl:otherwise>
<xsl:choose>
<xsl:when test="name()='dateTimeFormats'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">dateTime</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select="*">
<xsl:call-template name="dateTimeFormats"></xsl:call-template>
</xsl:for-each>
@@ -416,16 +423,6 @@
<xsl:if test="name()!='default'">
<!-- patterns -->
<xsl:if test="name()='dateTimeFormatLength'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">dateTimeFormat</xsl:with-param>
- <xsl:with-param name="bundle" select="../../@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select=".//pattern[not(@draft)] |
.//pattern[@draft!='provisional' and @draft!='unconfirmed']">
<xsl:call-template name="insert_comma"/>
@@ -444,30 +441,10 @@
count(*[@draft!='provisional' and @draft!='unconfirmed'])>0">
<xsl:call-template name="insert_comma"/>
'dateTimeAvailableFormats':<xsl:call-template name="subSelect"><xsl:with-param name="name" select="dateFormatItem"></xsl:with-param></xsl:call-template>
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">dateTimeAvailableFormats</xsl:with-param>
- <xsl:with-param name="bundle" select="../../@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
</xsl:if>
</xsl:if>
<!-- appendItems -->
<xsl:if test="name()='appendItems'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">dateTimeFormats-appendItem-</xsl:with-param>
- <xsl:with-param name="bundle" select="../../@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select=".//appendItem[not(@draft)] |
.//appendItem[@draft!='provisional' and @draft!='unconfirmed']">
<xsl:call-template name="insert_comma"/>
@@ -489,6 +466,24 @@
<xsl:param name="width" select="@type"></xsl:param>
<!-- will be overridden with 'true' if from alias, see 'invoke_template_by_name' -->
<xsl:param name="fromLocaleAlias" select="false()"/>
+
+ <!-- insert 'locale' alias information start -->
+ <xsl:if test="$fromLocaleAlias">
+ <xsl:if test="name()='fields'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName">field</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="name() = 'field'">
+ <xsl:call-template name="insert_alias_info">
+ <xsl:with-param name="sourceName" select="concat(name(), '-', $width)"/>
+ <xsl:with-param name="targetName" select="concat(name(), '-', @type)"/>
+ <xsl:with-param name="bundle" select="../../@type"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ <!-- insert 'locale' alias information end -->
+
<xsl:choose>
<xsl:when test="count(./alias)>0">
<!-- Handle Alias -->
@@ -504,31 +499,11 @@
<xsl:otherwise>
<xsl:choose>
<xsl:when test="name()='fields'">
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName">field</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select="*">
<xsl:call-template name="fields"></xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
-
- <!-- insert 'locale' alias information start -->
- <xsl:if test="$fromLocaleAlias and name() = 'field'">
- <xsl:call-template name="insert_alias_info">
- <xsl:with-param name="sourceName" select="concat(name(), '-', $width)"/>
- <xsl:with-param name="targetName" select="concat(name(), '-', @type)"/>
- <xsl:with-param name="bundle" select="../../@type"/>
- </xsl:call-template>
- </xsl:if>
- <!-- insert 'locale' alias information end -->
-
<xsl:for-each select=".//displayName[not(@draft)] |
.//displayName[@draft!='provisional' and @draft!='unconfirmed']">
<xsl:call-template name="insert_comma"/>
Modified: util/trunk/buildscripts/cldr/specialLocale.js
==============================================================================
--- util/trunk/buildscripts/cldr/specialLocale.js (original)
+++ util/trunk/buildscripts/cldr/specialLocale.js Wed Sep 10 11:49:25 2008
@@ -141,13 +141,13 @@
break;
}else if(!aliasBundle && srcBundle){
//should be an error case
- logStr += 'specialLocale.js error: source locale has more bundles than alias locale\n';
+ //logStr += 'specialLocale.js error: source locale has more bundles than alias locale\n';
break;
}else if(aliasBundle && !srcBundle){
//add the new bundle to source locale
validateDir(srcLocalePath);
fileUtil.saveUtf8File(srcLocalePath + '/' + BUNDLE_MAP[len] + '.js', NLS_JSON_HEAD[len] + '(' + dojo.toJson(aliasBundle, true) + ')');
- logStr += "specialLocale.js : copied " + BUNDLE_MAP[len] + '.js to ' + srcLocalePath + '\n';
+ //logStr += "specialLocale.js : copied " + BUNDLE_MAP[len] + '.js to ' + srcLocalePath + '\n';
}else if(aliasBundle && srcBundle){
var isUpdated = false;
//get native bundle whose content is not flattened
@@ -171,13 +171,13 @@
if(isUpdated){
validateDir(srcLocalePath);
fileUtil.saveUtf8File(srcLocalePath + '/' + BUNDLE_MAP[len] + '.js', NLS_JSON_HEAD[len] + '(' + dojo.toJson(nativeSrcBundle, true) + ')');
- logStr += 'specialLocale.js : updated ' + BUNDLE_MAP[len] + '.js in ' + srcLocalePath + '\n';
+ //logStr += 'specialLocale.js : updated ' + BUNDLE_MAP[len] + '.js in ' + srcLocalePath + '\n';
}
}
}
}
-fileUtil.saveUtf8File(logDir + '/specialLocale.log',logStr+'\n');
+//fileUtil.saveUtf8File(logDir + '/specialLocale.log',logStr+'\n');
function validateDir(/*String*/dirPath){
//summary:make sure the dir exists
More information about the Dojo-checkins
mailing list