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

Remove locales from public #450

Merged
merged 3 commits into from
Aug 12, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions client/startup/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ Meteor.startup ->
lng = lng.replace re, (match, parts...) -> return parts[0] + parts[1].toUpperCase()
return lng

loadedLaguages = []

setLanguage = (language) ->
if loadedLaguages.indexOf(language) > -1
return

loadedLaguages.push language

language = language.split('-').shift()
TAPi18n.setLanguage(language)

language = language.toLowerCase()
if language isnt 'en'
Meteor.call 'loadLocale', language, (data) ->
moment.locale(language)

languageComputation = Tracker.autorun ->
if Meteor.user()?.language
userLanguage = Meteor.user().language
if Meteor.user()?.language?
languageComputation.stop()
else
userLanguage = defaultUserLanguage()
localStorage.setItem("userLanguage", userLanguage)

userLanguage = userLanguage.split('-').shift()
TAPi18n.setLanguage(userLanguage)
localStorage.setItem("userLanguage", Meteor.user().language)
setLanguage Meteor.user().language

userLanguage = localStorage.getItem("userLanguage")
userLanguage ?= defaultUserLanguage()

filename = "/moment-locales/#{userLanguage.toLowerCase()}.js"
if filename isnt '/moment-locales/en.js'
$.getScript filename, (data) ->
moment.locale(userLanguage)
setLanguage userLanguage
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions server/methods/loadLocale.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Meteor.methods
loadLocale: (locale) ->
console.log "[method] loadLocale: #{locale}".green
try
return Assets.getText "moment-locales/#{locale.toLowerCase()}.js"
catch e
console.log e