seamless localization + FR locale

This commit is contained in:
elclanrs 2013-10-10 18:07:06 -04:00
parent 622bca22ab
commit ca575cbd7f
6 changed files with 35 additions and 38 deletions

View file

@ -366,7 +366,7 @@ $('form').idealforms({
}); });
``` ```
### Extension: Dynamic Fields ### Extension - Dynamic Fields
**Name:** `dynamicFields` **Name:** `dynamicFields`
@ -497,7 +497,7 @@ $('form').idealforms('toggleFields', 'username password hobbies[]');
Dynamic Fields adds injection points for `addFields`, `removeFields` and `toggleFields`. Read about [custom extensions](#custom-extensions) for more info. Dynamic Fields adds injection points for `addFields`, `removeFields` and `toggleFields`. Read about [custom extensions](#custom-extensions) for more info.
### Extension: Steps ### Extension - Steps
**Name:** `steps` **Name:** `steps`
@ -597,7 +597,7 @@ Steps adds the `appendToStep:index` option to `addFields`:
$('form').addFields({ 'field': { type: 'text', label: 'Field', appendToStep: 1 }}); $('form').addFields({ 'field': { type: 'text', label: 'Field', appendToStep: 1 }});
``` ```
### Extension: Custom Inputs ### Extension - Custom Inputs
Adds custom checkboxes, radios and file inputs (yes!) seamlessly. The custom select menu has been dropped from Ideal Forms 3; it was proving to be a pain to maintain, and there are much better alternatives, such as [Select2](http://ivaynberg.github.io/select2/) if you need them. Adds custom checkboxes, radios and file inputs (yes!) seamlessly. The custom select menu has been dropped from Ideal Forms 3; it was proving to be a pain to maintain, and there are much better alternatives, such as [Select2](http://ivaynberg.github.io/select2/) if you need them.
@ -605,7 +605,7 @@ Adds custom checkboxes, radios and file inputs (yes!) seamlessly. The custom sel
This extension has no additional options or methods. This extension has no additional options or methods.
### Extension: Ajax ### Extension - Ajax
**Name:** `ajax` **Name:** `ajax`
@ -640,7 +640,7 @@ echo json_encode(true);
If the response gets delayed the field will switch into "ajax mode" by showing a loading icon until the response comes back. If the response gets delayed the field will switch into "ajax mode" by showing a loading icon until the response comes back.
### Extension: Datepicker ### Extension - Datepicker
**Name:** `datepicker` **Name:** `datepicker`
@ -671,7 +671,7 @@ $('form').idealforms({
$('.datepicker').datepicker('option', 'dateFormat', 'yy-mm-dd'); $('.datepicker').datepicker('option', 'dateFormat', 'yy-mm-dd');
``` ```
### Extension: Adaptive ### Extension - Adaptive
**Name:** `adaptive` **Name:** `adaptive`
@ -772,18 +772,11 @@ _init: function() {
## Localization ## Localization
To localize Ideal Forms load the corresponding i18n file from `js/i18n` **after** the plugin and pass the `i18n` option: To localize Ideal Forms load the corresponding i18n file from `js/i18n` **after** the plugin:
```html ```html
<script src="jquery.idealforms.js"></script> <script src="jquery.idealforms.js"></script>
<script src="jquery.idealforms.i18n.es.js"></script> <script src="jquery.idealforms.i18n.es.js"></script>
<script>
$('form').idealforms({
i18n: 'es',
...
});
</script>
``` ```
Creating your own locale file: Creating your own locale file:

View file

@ -201,7 +201,7 @@
<!--<script src="js/out/jquery.idealforms.min.js"></script>--> <!--<script src="js/out/jquery.idealforms.min.js"></script>-->
<script> <script>
$('form').idealforms({ $('form.idealforms').idealforms({
rules: { rules: {
'username': 'required username ajax', 'username': 'required username ajax',
@ -228,21 +228,21 @@
} }
}); });
$('form').find('input, select, textarea').on('change keyup', function() { $('form.idealforms').find('input, select, textarea').on('change keyup', function() {
$('#invalid').hide(); $('#invalid').hide();
}); });
$('form').idealforms('addRules', { $('form.idealforms').idealforms('addRules', {
'comments': 'required minmax:50:200' 'comments': 'required minmax:50:200'
}); });
$('.prev').click(function(){ $('.prev').click(function(){
$('.prev').show(); $('.prev').show();
$('form').idealforms('prevStep'); $('form.idealforms').idealforms('prevStep');
}); });
$('.next').click(function(){ $('.next').click(function(){
$('.next').show(); $('.next').show();
$('form').idealforms('nextStep'); $('form.idealforms').idealforms('nextStep');
}); });
</script> </script>

View file

@ -30,7 +30,7 @@ $.idealforms.i18n.es = {
maxoption: 'No puede haber más de {0} opciones seleccionadas', maxoption: 'No puede haber más de {0} opciones seleccionadas',
minmax: 'Debe contener al menos {0} pero no más de {1} caracteres', minmax: 'Debe contener al menos {0} pero no más de {1} caracteres',
select: 'Selecciona una option', select: 'Selecciona una option',
extension: 'Los ficheros deben tener una extensión válida', extension: 'Los ficheros deben tener una extensión válida ({*})',
equalto: 'Debe ser idéntico a <strong>"{0}"</strong>', equalto: 'Debe ser idéntico a <strong>"{0}"</strong>',
date: 'Debe ser una fecha válida {0}', date: 'Debe ser una fecha válida {0}',
ajax: 'Cargando...' ajax: 'Cargando...'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -34,18 +34,20 @@ module.exports = {
_i18n: function() { _i18n: function() {
if (this.opts.i18n == 'en') return; var self = this;
var lang = $.idealforms.i18n[this.opts.i18n] $.each($.idealforms.i18n, function(locale, lang) {
, errors = lang.errors
, options = {};
delete lang.errors; var errors = lang.errors
, options = {};
for (var ext in lang) options[ext] = { i18n: lang[ext] }; delete lang.errors;
$.extend($.idealforms.errors, errors); for (var ext in lang) options[ext] = { i18n: lang[ext] };
$.extend(true, this.opts, options);
$.extend($.idealforms.errors, errors);
$.extend(true, self.opts, options);
});
}, },
_buildField: function(input) { _buildField: function(input) {