improvements supplier translations
This commit is contained in:
@@ -32,6 +32,10 @@
|
|||||||
//= require qwaiter
|
//= require qwaiter
|
||||||
//= require_directory .
|
//= require_directory .
|
||||||
//= require_self
|
//= require_self
|
||||||
|
var Qstorage = localStorage;
|
||||||
|
String.prototype.capitalize = function() {
|
||||||
|
return this.charAt(0).toUpperCase() + this.slice(1);
|
||||||
|
}
|
||||||
var path_mapping = {
|
var path_mapping = {
|
||||||
user_root: '/user',
|
user_root: '/user',
|
||||||
join_occupied_table: '/user/join_occupied_table',
|
join_occupied_table: '/user/join_occupied_table',
|
||||||
@@ -49,3 +53,15 @@ function redirect_to(mapping, variables){
|
|||||||
function currency(num) {
|
function currency(num) {
|
||||||
return Qwaiter.currency(num);
|
return Qwaiter.currency(num);
|
||||||
}
|
}
|
||||||
|
$(function(){
|
||||||
|
$locale = Qstorage.getItem('locale') || 'en';
|
||||||
|
if(Qstorage.getItem('message')){
|
||||||
|
var container = $('.alert-success');
|
||||||
|
var msg_finder = Qstorage.getItem('message');
|
||||||
|
if(msg_finder.indexOf('.') == -1) msg_finder = 'messages.'+msg_finder;
|
||||||
|
container.find('div').text(t(msg_finder));
|
||||||
|
container.show();
|
||||||
|
Qstorage.removeItem('message');
|
||||||
|
}
|
||||||
|
setTranslations();
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
var $translations = {
|
||||||
|
en: {
|
||||||
|
messages: <%= I18n.t('messages', locale: :en).to_json %>,
|
||||||
|
models: <%= I18n.t('activemodel.models', locale: :en).to_json %>,
|
||||||
|
attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>,
|
||||||
|
<%= I18n.t('supplier', locale: :en).to_json[1..-2] %>
|
||||||
|
},
|
||||||
|
nl: {
|
||||||
|
models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>,
|
||||||
|
attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>,
|
||||||
|
<%= I18n.t('supplier', locale: :nl).to_json[1..-2] %>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$transformation_mappings = {
|
||||||
|
downcase: 'toLowerCase',
|
||||||
|
upcase: 'toUpperCase'
|
||||||
|
}
|
||||||
|
function t(path, vars){
|
||||||
|
vars || (vars = {});
|
||||||
|
var result, m, translatable, isafety,replacable;
|
||||||
|
var parts = path.split('.');
|
||||||
|
var accessor = '$translations.'+$locale+'["' + parts.join('"]["')+ '"]';
|
||||||
|
try{
|
||||||
|
result = eval(accessor);
|
||||||
|
} catch(err){
|
||||||
|
result = parts[parts.length - 1].capitalize();
|
||||||
|
}
|
||||||
|
if(!result) return parts[parts.length - 1].capitalize();
|
||||||
|
$.each(vars, function(v, value){ result = result.replace('%{'+v+'}', value)});
|
||||||
|
isafety = 0;
|
||||||
|
while(result.indexOf('${') > -1){
|
||||||
|
m = result.match(/\${([\w\.]+(\|\w+)?)}/);
|
||||||
|
if(m[2]){
|
||||||
|
translatable = m[1].replace(m[2], '');
|
||||||
|
operation = $transformation_mappings[m[2].substr(1) || m[2].substr(1)];
|
||||||
|
}else{
|
||||||
|
translatable = m[1];
|
||||||
|
operation = null;
|
||||||
|
}
|
||||||
|
replacable = t(translatable);
|
||||||
|
if(operation) replacable = replacable[operation]();
|
||||||
|
result = result.replace(m[0], replacable);
|
||||||
|
if(isafety > 10) break;
|
||||||
|
isafety += 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
function setLocale(locale){
|
||||||
|
Qstorage.setItem('locale', locale);
|
||||||
|
$locale = locale;
|
||||||
|
setTranslations();
|
||||||
|
}
|
||||||
|
function setTranslations(selector){
|
||||||
|
var list = $('#top-navigation-list');
|
||||||
|
list.find('.locale').show();
|
||||||
|
list.find('.locale-'+$locale).hide();
|
||||||
|
if(selector){
|
||||||
|
$(selector).find('[data-t]').each(function(){$(this).text(t($(this).data('t'), $(this).data('tAttributes')))})
|
||||||
|
}else{
|
||||||
|
$('[data-t]').each(function(){$(this).text(t($(this).data('t'),$(this).data('tAttributes')))})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,7 @@ class Section
|
|||||||
w = width
|
w = width
|
||||||
h = height
|
h = height
|
||||||
n = tables.size
|
n = tables.size
|
||||||
|
return unless w > 0 && h > 0 && n > 0
|
||||||
l = Math.sqrt((w*h).to_f/n)
|
l = Math.sqrt((w*h).to_f/n)
|
||||||
epsilon = (10 ** -(Float::DIG - 1)).to_f
|
epsilon = (10 ** -(Float::DIG - 1)).to_f
|
||||||
while (w/l).floor * (h/l).floor < n # find a fitting combination
|
while (w/l).floor * (h/l).floor < n # find a fitting combination
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Supplier
|
|||||||
private
|
private
|
||||||
|
|
||||||
def add_section_on_create
|
def add_section_on_create
|
||||||
@section = Section.create supplier: self, title: I18n.t('section.first_section_title')
|
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- model_class = Section
|
- model_class = Section
|
||||||
.page-header= title t('section.manage_tables.title', section: Section.model_name.human.downcase, title: @section.title)
|
.page-header data-t='section.manage_tables.title' data-t-attributes=%|{"title":"#{@section.title}"}|
|
||||||
- content_for :row do
|
- content_for :row do
|
||||||
ul.nav.nav-tabs
|
ul.nav.nav-tabs
|
||||||
- for section in @section.supplier.sections
|
- for section in @section.supplier.sections
|
||||||
@@ -62,8 +62,8 @@
|
|||||||
.controls
|
.controls
|
||||||
input.input-mini#add-tables-number-end type=:number value=120
|
input.input-mini#add-tables-number-end type=:number value=120
|
||||||
.modal-footer
|
.modal-footer
|
||||||
button.btn data-dismiss="modal" aria-hidden=true Close
|
button.btn data-dismiss="modal" aria-hidden=true data-t='section.add_tables.modal.close_button'
|
||||||
button.btn.btn-primary onclick="Qsupplier.add_tables_to_active_section()" Add
|
button.btn.btn-primary onclick="Qsupplier.add_tables_to_active_section()" data-t='section.add_tables.modal.add_button'
|
||||||
#arrange-tables-modal.modal.hide.fade tabindex=-1 role=:dialog aria-labeledby='add-tables-modal-label' aria-hidden=true
|
#arrange-tables-modal.modal.hide.fade tabindex=-1 role=:dialog aria-labeledby='add-tables-modal-label' aria-hidden=true
|
||||||
button.close type=:button data-dismiss=:modal aria-hidden=true x
|
button.close type=:button data-dismiss=:modal aria-hidden=true x
|
||||||
h3#arrange-tables-modal-label= t('supplier.section.arrange_tables.modal.title')
|
h3#arrange-tables-modal-label= t('supplier.section.arrange_tables.modal.title')
|
||||||
@@ -87,5 +87,5 @@
|
|||||||
label for="arrange-tables-by-column-count"= t('supplier.section.arrange_tables.modal.by_column_count')
|
label for="arrange-tables-by-column-count"= t('supplier.section.arrange_tables.modal.by_column_count')
|
||||||
input.input-mini#arrange-tables-by-column-count type="text" value=0
|
input.input-mini#arrange-tables-by-column-count type="text" value=0
|
||||||
.modal-footer
|
.modal-footer
|
||||||
button.btn data-dismiss="modal" aria-hidden=true Close
|
button.btn data-dismiss="modal" aria-hidden=true data-t='section.arrange_tables.modal.close_button'
|
||||||
button.btn.btn-primary onclick="Qsupplier.arrange_tables_of_active_section()" Add
|
button.btn.btn-primary onclick="Qsupplier.arrange_tables_of_active_section()" data-t='section.arrange_tables.modal.arrange_button'
|
||||||
|
|||||||
+16
-4
@@ -110,15 +110,31 @@ en:
|
|||||||
show:
|
show:
|
||||||
title: Show %{list}
|
title: Show %{list}
|
||||||
section:
|
section:
|
||||||
|
first_section_title: Room
|
||||||
|
manage_tables:
|
||||||
|
title: "Manage tables for ${models.section|downcase}: %{title}"
|
||||||
tables_view: Tables view
|
tables_view: Tables view
|
||||||
add_tables:
|
add_tables:
|
||||||
button_label: Add tables
|
button_label: Add tables
|
||||||
modal:
|
modal:
|
||||||
title: Add tables
|
title: Add tables
|
||||||
|
body_header: ""
|
||||||
|
number_start: From number
|
||||||
|
number_end: Till number
|
||||||
|
close_button: Close
|
||||||
|
add_button: Add
|
||||||
arrange_tables:
|
arrange_tables:
|
||||||
button_label: Arrange tables
|
button_label: Arrange tables
|
||||||
modal:
|
modal:
|
||||||
title: Arrange tables
|
title: Arrange tables
|
||||||
|
body_header: ""
|
||||||
|
distributed: Distributed
|
||||||
|
by_row: By row
|
||||||
|
by_row_count: of
|
||||||
|
by_column: By column
|
||||||
|
by_column_count: of
|
||||||
|
close_button: Close
|
||||||
|
arrange_button: Distribute
|
||||||
|
|
||||||
user:
|
user:
|
||||||
active_list:
|
active_list:
|
||||||
@@ -148,10 +164,6 @@ en:
|
|||||||
title: Authenticate Qwaiter
|
title: Authenticate Qwaiter
|
||||||
obtain: Authenticate
|
obtain: Authenticate
|
||||||
invalid_combination: The email password combination is incorrect
|
invalid_combination: The email password combination is incorrect
|
||||||
section:
|
|
||||||
first_section_title: Room
|
|
||||||
manage_tables:
|
|
||||||
title: "Manage tables for %{section}: %{title}"
|
|
||||||
general:
|
general:
|
||||||
boolean:
|
boolean:
|
||||||
boolean_yes: "Yes"
|
boolean_yes: "Yes"
|
||||||
|
|||||||
+12
-4
@@ -94,6 +94,11 @@ nl:
|
|||||||
title: Titel
|
title: Titel
|
||||||
width: Breedte
|
width: Breedte
|
||||||
height: Lengte
|
height: Lengte
|
||||||
|
supplier:
|
||||||
|
name: Naam
|
||||||
|
email: 'E-mail'
|
||||||
|
password: 'Wachtwoord'
|
||||||
|
password_confirmation: 'Bevestiging'
|
||||||
supplier:
|
supplier:
|
||||||
menu:
|
menu:
|
||||||
active_lists: Actieve %{lists}
|
active_lists: Actieve %{lists}
|
||||||
@@ -114,6 +119,9 @@ nl:
|
|||||||
show:
|
show:
|
||||||
title: "%{list} tonen"
|
title: "%{list} tonen"
|
||||||
section:
|
section:
|
||||||
|
first_section_title: Ruimte
|
||||||
|
manage_tables:
|
||||||
|
title: "Tafels beheren voor ${models.section|downcase}: %{title}"
|
||||||
tables_view: Tafel overzicht
|
tables_view: Tafel overzicht
|
||||||
add_tables:
|
add_tables:
|
||||||
button_label: Voeg tafels toe
|
button_label: Voeg tafels toe
|
||||||
@@ -122,6 +130,8 @@ nl:
|
|||||||
body_header: ""
|
body_header: ""
|
||||||
number_start: Vanaf nummer
|
number_start: Vanaf nummer
|
||||||
number_end: Tot nummer
|
number_end: Tot nummer
|
||||||
|
close_button: Sluiten
|
||||||
|
add_button: Voeg toe
|
||||||
arrange_tables:
|
arrange_tables:
|
||||||
button_label: Positioneer tafels
|
button_label: Positioneer tafels
|
||||||
modal:
|
modal:
|
||||||
@@ -132,6 +142,8 @@ nl:
|
|||||||
by_row_count: van
|
by_row_count: van
|
||||||
by_column: Per kolom
|
by_column: Per kolom
|
||||||
by_column_count: van
|
by_column_count: van
|
||||||
|
close_button: Sluiten
|
||||||
|
arrange_button: Positioneer
|
||||||
|
|
||||||
user:
|
user:
|
||||||
active_list:
|
active_list:
|
||||||
@@ -161,10 +173,6 @@ nl:
|
|||||||
title: Aanmelden bij Qwaiter
|
title: Aanmelden bij Qwaiter
|
||||||
obtain: Aanmelden
|
obtain: Aanmelden
|
||||||
invalid_combination: De inloggegevens zijn onjuist
|
invalid_combination: De inloggegevens zijn onjuist
|
||||||
section:
|
|
||||||
first_section_title: Ruimte
|
|
||||||
manage_tables:
|
|
||||||
title: "Tafels beheren voor %{section}: %{title}"
|
|
||||||
general:
|
general:
|
||||||
boolean:
|
boolean:
|
||||||
boolean_yes: "Ja"
|
boolean_yes: "Ja"
|
||||||
|
|||||||
Reference in New Issue
Block a user