Skip to content

Commit

Permalink
Merge pull request #503 from Knockout-Contrib/issue-492
Browse files Browse the repository at this point in the history
Make localization files AMD and CommonJS/Node compatible
  • Loading branch information
crissdev committed Jan 13, 2015
2 parents 19be216 + b29a8aa commit 9f9c060
Show file tree
Hide file tree
Showing 33 changed files with 1,346 additions and 815 deletions.
12 changes: 6 additions & 6 deletions Dist/knockout.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,16 +1392,16 @@ kv.validateObservable = function (observable) {
;
//quick function to override rule messages
kv.localize = function (msgTranslations) {

var msg, rule;
var rules = kv.rules;

//loop the properties in the object and assign the msg to the rule
for (rule in msgTranslations) {
if (kv.rules.hasOwnProperty(rule)) {
kv.rules[rule].message = msgTranslations[rule];
for (var ruleName in msgTranslations) {
if (rules.hasOwnProperty(ruleName)) {
rules[ruleName].message = msgTranslations[ruleName];
}
}
};;/**
};
;/**
* Possible invocations:
* applyBindingsWithValidation(viewModel)
* applyBindingsWithValidation(viewModel, options)
Expand Down
2 changes: 1 addition & 1 deletion Dist/knockout.validation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Dist/knockout.validation.min.js.map

Large diffs are not rendered by default.

73 changes: 46 additions & 27 deletions Localization/bg-BG.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
/// <reference path="../Src/knockout.validation.js" />

/************************************************
* This is an example localization page. All of these
* messages are the default messages for ko.validation
*
* Currently ko.validation only does a single parameter replacement
* on your message (indicated by the {0}).
*
* The parameter that you provide in your validation extender
* is what is passed to your message to do the {0} replacement.
* Currently ko.validation does multiple parameter replacement
* on your message (indicated by the {0}, {1}, etc.).
*
* The parameters that you provide in your validation extender
* are what are passed to your message to do the {0}, {1} etc. replacements.
*
* eg: myProperty.extend({ minLength: 5 });
* ... will provide a message of "Please enter at least 5 characters"
* when validated
*
* eg: myProperty.extend({ between: [1, 5] });
* ... will provide a message of "Please enter between 1 and 5 characters"
* when validated
*
* This message replacement obviously only works with primitives
* such as numbers and strings. We do not stringify complex objects
* such as numbers and strings. We do not stringify complex objects
* or anything like that currently.
*/

ko.validation.localize({
required: 'Моля, въведете стойност.',
min: 'Моля, въведете стойност по-голяма или равна на {0}.',
max: 'Моля, въведете стойност по-малка или равна на {0}.',
minLength: 'Моля, въведете поне {0} символа.',
maxLength: 'Моля, въведете по-малко от {0} символа.',
pattern: 'Моля, проверете тази стойност.',
step: 'Стойността трябва да се увеличава с {0}.',
email: 'Това не е валиден e-mail адрес.',
date: 'Моля, въведете валидна дата.',
dateISO: 'Моля, въведете валидна дата.',
number: 'Моля, въведете число.',
digit: 'Моля, въведете цифра.',
phoneUS: 'Моля, въведете валиден телефонен номер.',
equal: 'Стойностите трябва да са равни.',
notEqual: 'Моля, изберете различна стойност.',
unique: 'Моля, убедете се, че стойността е уникална.'
});
(function(factory) {
// Module systems magic dance.
/*global require,ko,define*/
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node: hard-coded dependency on "knockout"
factory(require("knockout"));
} else if (typeof define === "function" && define["amd"]) {
// AMD anonymous module with hard-coded dependency on "knockout"
define(["knockout"], factory);
} else {
// <script> tag: use the global `ko` object, attaching a `mapping` property
factory(ko);
}
}(function(ko) {
if (!ko.validation && typeof ko.validation.localize !== 'function') {
throw new Error('Knockout-Validation is required, please ensure it is loaded before this localization file');
}
ko.validation.localize({
required: 'Моля, въведете стойност.',
min: 'Моля, въведете стойност по-голяма или равна на {0}.',
max: 'Моля, въведете стойност по-малка или равна на {0}.',
minLength: 'Моля, въведете поне {0} символа.',
maxLength: 'Моля, въведете по-малко от {0} символа.',
pattern: 'Моля, проверете тази стойност.',
step: 'Стойността трябва да се увеличава с {0}.',
email: 'Това не е валиден e-mail адрес.',
date: 'Моля, въведете валидна дата.',
dateISO: 'Моля, въведете валидна дата.',
number: 'Моля, въведете число.',
digit: 'Моля, въведете цифра.',
phoneUS: 'Моля, въведете валиден телефонен номер.',
equal: 'Стойностите трябва да са равни.',
notEqual: 'Моля, изберете различна стойност.',
unique: 'Моля, убедете се, че стойността е уникална.'
});
}));
73 changes: 46 additions & 27 deletions Localization/ca-CA.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
/// <reference path="../Src/knockout.validation.js" />

/************************************************
* This is an example localization page. All of these
* messages are the default messages for ko.validation
*
* Currently ko.validation only does a single parameter replacement
* on your message (indicated by the {0}).
*
* The parameter that you provide in your validation extender
* is what is passed to your message to do the {0} replacement.
* Currently ko.validation does multiple parameter replacement
* on your message (indicated by the {0}, {1}, etc.).
*
* The parameters that you provide in your validation extender
* are what are passed to your message to do the {0}, {1} etc. replacements.
*
* eg: myProperty.extend({ minLength: 5 });
* ... will provide a message of "Please enter at least 5 characters"
* when validated
*
* eg: myProperty.extend({ between: [1, 5] });
* ... will provide a message of "Please enter between 1 and 5 characters"
* when validated
*
* This message replacement obviously only works with primitives
* such as numbers and strings. We do not stringify complex objects
* such as numbers and strings. We do not stringify complex objects
* or anything like that currently.
*/

ko.validation.localize({
required: 'Aquest camp es obligatori',
min: 'Introduir un valor igual o major que {0}',
max: 'Introduir un valor menor o igual que {0}',
minLength: 'Ha de tenir un mínim de {0} caràcters',
maxLength: 'No pot tenir mes de {0} caràcters',
pattern: 'Si us plau, comproveu aquest campo',
step: "El valor ha d'incrementar-se en {0}",
email: 'Aquesta no es una adreça de correu electrònic correcta',
date: 'Introduir una data correcta',
dateISO: 'Introduir una data correcta',
number: 'Ha de ser un nombre',
digit: 'Introduir un dígit',
phoneUS: 'Ha de ser un número de telèfon vàlid',
equal: 'Els valors han de ser iguals',
notEqual: 'Elegiu un altre valor',
unique: 'Ha de ser un valor únic'
});
(function(factory) {
// Module systems magic dance.
/*global require,ko,define*/
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node: hard-coded dependency on "knockout"
factory(require("knockout"));
} else if (typeof define === "function" && define["amd"]) {
// AMD anonymous module with hard-coded dependency on "knockout"
define(["knockout"], factory);
} else {
// <script> tag: use the global `ko` object, attaching a `mapping` property
factory(ko);
}
}(function(ko) {
if (!ko.validation && typeof ko.validation.localize !== 'function') {
throw new Error('Knockout-Validation is required, please ensure it is loaded before this localization file');
}
ko.validation.localize({
required: 'Aquest camp es obligatori',
min: 'Introduir un valor igual o major que {0}',
max: 'Introduir un valor menor o igual que {0}',
minLength: 'Ha de tenir un mínim de {0} caràcters',
maxLength: 'No pot tenir mes de {0} caràcters',
pattern: 'Si us plau, comproveu aquest campo',
step: "El valor ha d'incrementar-se en {0}",
email: 'Aquesta no es una adreça de correu electrònic correcta',
date: 'Introduir una data correcta',
dateISO: 'Introduir una data correcta',
number: 'Ha de ser un nombre',
digit: 'Introduir un dígit',
phoneUS: 'Ha de ser un número de telèfon vàlid',
equal: 'Els valors han de ser iguals',
notEqual: 'Elegiu un altre valor',
unique: 'Ha de ser un valor únic'
});
}));
73 changes: 46 additions & 27 deletions Localization/cs-CZ.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
/// <reference path="../Src/knockout.validation.js" />

/************************************************
* This is an example localization page. All of these
* messages are the default messages for ko.validation
*
* Currently ko.validation only does a single parameter replacement
* on your message (indicated by the {0}).
*
* The parameter that you provide in your validation extender
* is what is passed to your message to do the {0} replacement.
* Currently ko.validation does multiple parameter replacement
* on your message (indicated by the {0}, {1}, etc.).
*
* The parameters that you provide in your validation extender
* are what are passed to your message to do the {0}, {1} etc. replacements.
*
* eg: myProperty.extend({ minLength: 5 });
* ... will provide a message of "Please enter at least 5 characters"
* when validated
*
* eg: myProperty.extend({ between: [1, 5] });
* ... will provide a message of "Please enter between 1 and 5 characters"
* when validated
*
* This message replacement obviously only works with primitives
* such as numbers and strings. We do not stringify complex objects
* such as numbers and strings. We do not stringify complex objects
* or anything like that currently.
*/

ko.validation.localize({
required: 'Toto pole je povinné.',
min: 'Zadejte číslo větší nebo rovné {0}.',
max: 'Zadejte číslo menší nebo rovné {0}.',
minLength: 'Vložte alespoň {0} znaků.',
maxLength: 'Vložte nejvíce {0} znaků.',
pattern: 'Zkontrolujte formát pole.',
step: 'Hodnota musí být násobek {0}.',
email: 'Neplatná e-mailová adresa.',
date: 'Zadejte platné datum.',
dateISO: 'Zadejte platné datum.',
number: 'Zadejte číslo.',
digit: 'Zadejte číslice.',
phoneUS: 'Zadejte platné telefonní číslo.',
equal: 'Hodnoty musí být stejné.',
notEqual: 'Vyberte jinou hodnotu.',
unique: 'Zkontrolujte, zda hodnota je jedinečná.'
});
(function(factory) {
// Module systems magic dance.
/*global require,ko,define*/
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node: hard-coded dependency on "knockout"
factory(require("knockout"));
} else if (typeof define === "function" && define["amd"]) {
// AMD anonymous module with hard-coded dependency on "knockout"
define(["knockout"], factory);
} else {
// <script> tag: use the global `ko` object, attaching a `mapping` property
factory(ko);
}
}(function(ko) {
if (!ko.validation && typeof ko.validation.localize !== 'function') {
throw new Error('Knockout-Validation is required, please ensure it is loaded before this localization file');
}
ko.validation.localize({
required: 'Toto pole je povinné.',
min: 'Zadejte číslo větší nebo rovné {0}.',
max: 'Zadejte číslo menší nebo rovné {0}.',
minLength: 'Vložte alespoň {0} znaků.',
maxLength: 'Vložte nejvíce {0} znaků.',
pattern: 'Zkontrolujte formát pole.',
step: 'Hodnota musí být násobek {0}.',
email: 'Neplatná e-mailová adresa.',
date: 'Zadejte platné datum.',
dateISO: 'Zadejte platné datum.',
number: 'Zadejte číslo.',
digit: 'Zadejte číslice.',
phoneUS: 'Zadejte platné telefonní číslo.',
equal: 'Hodnoty musí být stejné.',
notEqual: 'Vyberte jinou hodnotu.',
unique: 'Zkontrolujte, zda hodnota je jedinečná.'
});
}));
73 changes: 46 additions & 27 deletions Localization/da-DK.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
/// <reference path="../Src/knockout.validation.js" />

/************************************************
* This is an example localization page. All of these
* messages are the default messages for ko.validation
*
* Currently ko.validation only does a single parameter replacement
* on your message (indicated by the {0}).
*
* The parameter that you provide in your validation extender
* is what is passed to your message to do the {0} replacement.
* Currently ko.validation does multiple parameter replacement
* on your message (indicated by the {0}, {1}, etc.).
*
* The parameters that you provide in your validation extender
* are what are passed to your message to do the {0}, {1} etc. replacements.
*
* eg: myProperty.extend({ minLength: 5 });
* ... will provide a message of "Please enter at least 5 characters"
* when validated
*
* eg: myProperty.extend({ between: [1, 5] });
* ... will provide a message of "Please enter between 1 and 5 characters"
* when validated
*
* This message replacement obviously only works with primitives
* such as numbers and strings. We do not stringify complex objects
* such as numbers and strings. We do not stringify complex objects
* or anything like that currently.
*/

ko.validation.localize({
required: 'Dette felt er påkrævet.',
min: 'Angiv en værdi der mindst er {0}.',
max: 'Angiv en værdi der højst er {0}.',
minLength: 'Indtast mindst {0} tegn.',
maxLength: 'Indtast højst {0} tegn.',
pattern: 'Tjek venligst denne værdi.',
step: 'Værdien skal stige med {0}',
email: 'Dette er ikke en gyldig e-mail-adresse',
date: 'Indtast en gyldig dato',
dateISO: 'Indtast en gyldig dato',
number: 'Indtast et tal',
digit: 'Indtast et ciffer',
phoneUS: 'Indtast et gyldigt telefonnummer',
equal: 'Indtast den samme værdi igen.',
notEqual: 'Indtast en anden værdi.',
unique: 'Sørg for at værdien er unik.'
});
(function(factory) {
// Module systems magic dance.
/*global require,ko,define*/
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node: hard-coded dependency on "knockout"
factory(require("knockout"));
} else if (typeof define === "function" && define["amd"]) {
// AMD anonymous module with hard-coded dependency on "knockout"
define(["knockout"], factory);
} else {
// <script> tag: use the global `ko` object, attaching a `mapping` property
factory(ko);
}
}(function(ko) {
if (!ko.validation && typeof ko.validation.localize !== 'function') {
throw new Error('Knockout-Validation is required, please ensure it is loaded before this localization file');
}
ko.validation.localize({
required: 'Dette felt er påkrævet.',
min: 'Angiv en værdi der mindst er {0}.',
max: 'Angiv en værdi der højst er {0}.',
minLength: 'Indtast mindst {0} tegn.',
maxLength: 'Indtast højst {0} tegn.',
pattern: 'Tjek venligst denne værdi.',
step: 'Værdien skal stige med {0}',
email: 'Dette er ikke en gyldig e-mail-adresse',
date: 'Indtast en gyldig dato',
dateISO: 'Indtast en gyldig dato',
number: 'Indtast et tal',
digit: 'Indtast et ciffer',
phoneUS: 'Indtast et gyldigt telefonnummer',
equal: 'Indtast den samme værdi igen.',
notEqual: 'Indtast en anden værdi.',
unique: 'Sørg for at værdien er unik.'
});
}));
Loading

0 comments on commit 9f9c060

Please sign in to comment.