Created
November 21, 2013 13:00
-
-
Save stefanoortisi/7581165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localise_routes: ( ) -> | |
# Deep clone the default routes | |
old_routes = _.cloneDeep @Routes.routes | |
# Create a brand new routes object | |
@Routes.routes = {} | |
# Copy the utility routes | |
@Routes.routes[ "/pages" ] = old_routes[ "/pages" ] | |
# Create new routes with localised keys | |
for key, item of old_routes | |
if key isnt "/pages" | |
if key is "/" | |
_key = "homepage" | |
else | |
# Remove the / | |
_key = key.replace(/(\/\?\(:.+\)\?$)/g, "").substring 1 | |
# # Get the localised url from the xml | |
value = @dictionary.get( "item#" + _key + " url", "urls.xml" ) | |
value = key.replace "/" + _key, value | |
# # Create the item with the localised value | |
@Routes.routes[ value ] = item | |
# # Delete the old reference | |
item = null | |
if key is "/notfound" | |
@Routes.notfound = value | |
# Delete the old routes reference | |
old_routes = null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment