Solprovider Lenya Kongregate Registration for Free Flash Games and Chat with solprovider

Always use Language for Consistent URLs

My publication has much custom code generating URLs. Lenya URLs can be with or without the language. One choice is to add code to check if the current language is the default language, then add the language to the URL if it is not:
currentLangauge = getLanguage();
defaultLanguage = getDefaultLanguage();
if(currentLangauge == defaultLanguage){
newurl = base + "." + extension;
}else{
newurl = base + "_" + language + "." + extension;
}


In some places, this also requires code to parse the URL into base, language, and extension. And the code needs to be written for JS, XMAP, XSL, and XSP.

Or we could just always include the language. That is much less work, but many of the Lenya standard Navigation Elements do not include the language if it is the default. Luckily, all of the Lenya standard functions get the data from one place, so it is easy to fix. And yes, Lenya has extra code to check for the default language, so this "patch" is just removing code.

Instructions

To limit the change to one publication:
COPY:
build\lenya\webapp\lenya\xslt\navigation\sitetree2nav.xsl
TO:
{pub}\lenya\xslt\navigation\sitetree2nav.xsl

You could change the global file, but make a backup in case there is a publication that should use the default method.

In the file, change:
<xsl:variable name="canonical-language-suffix">
<xsl:choose>
<xsl:when test="$existinglanguage != '' and $defaultlanguage != $existinglanguage">
<xsl:value-of select="$language-suffix"/>
</xsl:when>
<xsl:otherwise>
<!-- no suffix for default language -->
</xsl:otherwise>
</xsl:choose>
</xsl:variable>


To:
<xsl:variable name="canonical-language-suffix">
<xsl:if test="$existinglanguage != ''">
<xsl:value-of select="$language-suffix"/>
</xsl:if>
</xsl:variable>


Then clear the cache: delete all files and subdirectories in {pub}/work/cache/live.

UPDATE 20050706: Fixed so no language does not add underscore. The Admin menu is not language-aware, and broke with this code.

<< Setting Visitor LanguageXMAP i18n >>

Contact Solprovider
Paul Ercolino