improve user client side translations

This commit is contained in:
2012-11-22 16:42:54 +01:00
parent 6251d07a5a
commit 88489804db
7 changed files with 40 additions and 17 deletions
+16 -4
View File
@@ -1,6 +1,6 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// a
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
@@ -68,10 +68,13 @@ var $translations = {
moved_to_another_table: 'The table is changed.',
confirmation_title: 'Move to another table?',
confirmation_body: 'Are you sure you want to move to another table?'
}
},
models: <%= I18n.t('activemodel.models', locale: :en).to_json %>,
attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>,
<%= I18n.t('user', locale: :en).to_json[1..-2] %>
},
nl: {
messages: <%= I18n.t('messages', locale: :en).to_json %>,
messages: <%= I18n.t('messages', locale: :nl).to_json %>,
confirmations: {
},
list_needs_help: {
@@ -99,7 +102,10 @@ var $translations = {
moved_to_another_table: 'De tafel is gewijzigd.',
confirmation_title: 'Naar een andere tafel verhuizen?',
confirmation_body: 'Ben je aan een andere tafel gaan zitten?'
}
},
models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>,
attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>,
<%= I18n.t('user', locale: :nl).to_json[1..-2] %>
}
}
function redirect_to(mapping, variables){
@@ -156,6 +162,7 @@ function getUrlVars() {
return $url_vars;
}
$(function(){
$locale = QMobile.locale();
if(getUrlVars().message){
var container = $('.alert-success');
// Prepend messages. if there is no path/period specified
@@ -170,3 +177,8 @@ $(function(){
}
$('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))})
});
function setLocale(locale){
QMobile.setLocale(locale);
$locale = locale;
$('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))})
}