gettext 1.2.0-mswin32 → 1.3.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +74 -0
- data/NEWS +16 -0
- data/README +9 -9
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/lib/gettext.rb +9 -4
- data/lib/gettext/locale.rb +11 -5
- data/lib/gettext/locale_cgi.rb +2 -5
- data/lib/gettext/locale_object.rb +68 -21
- data/lib/gettext/poparser.rb +2 -2
- data/lib/gettext/rails.rb +150 -30
- data/lib/gettext/version.rb +1 -1
- data/po/cs/rails.po +27 -27
- data/po/cs/rgettext.po +8 -8
- data/po/de/rails.po +28 -28
- data/po/de/rgettext.po +8 -8
- data/po/el/rails.po +25 -25
- data/po/el/rgettext.po +8 -8
- data/po/es/rails.po +25 -25
- data/po/es/rgettext.po +8 -8
- data/po/fr/rails.po +26 -26
- data/po/fr/rgettext.po +8 -8
- data/po/it/rgettext.po +8 -8
- data/po/ja/rails.po +23 -23
- data/po/ja/rgettext.po +8 -8
- data/po/ko/rails.po +23 -23
- data/po/ko/rgettext.po +8 -8
- data/po/nl/rails.po +25 -25
- data/po/nl/rgettext.po +8 -8
- data/po/pt_BR/rails.po +25 -25
- data/po/pt_BR/rgettext.po +8 -8
- data/po/rails.pot +25 -25
- data/po/rgettext.pot +8 -8
- data/po/sv/rgettext.po +8 -8
- data/samples/rails/README +3 -2
- data/samples/rails/Rakefile +6 -217
- data/samples/rails/app/controllers/application.rb +1 -0
- data/samples/rails/app/models/article.rb +7 -16
- data/samples/rails/config/database.yml +2 -1
- data/samples/rails/lib/tasks/gettext.rake +18 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/po/ja/blog.po +12 -0
- data/samples/rails/public/index.html +15 -17
- data/samples/rails/public/javascripts/controls.js +30 -1
- data/samples/rails/public/javascripts/dragdrop.js +210 -145
- data/samples/rails/public/javascripts/effects.js +261 -399
- data/samples/rails/public/javascripts/prototype.js +131 -72
- data/test/gettext_test.rb +5 -0
- data/test/gettext_test_locale.rb +133 -9
- metadata +5 -4
- data/samples/rails/script/benchmarker +0 -19
- data/samples/rails/script/profiler +0 -34
@@ -1,4 +1,4 @@
|
|
1
|
-
/* Prototype JavaScript framework, version 1.4.
|
1
|
+
/* Prototype JavaScript framework, version 1.4.0
|
2
2
|
* (c) 2005 Sam Stephenson <sam@conio.net>
|
3
3
|
*
|
4
4
|
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
|
@@ -11,7 +11,8 @@
|
|
11
11
|
/*--------------------------------------------------------------------------*/
|
12
12
|
|
13
13
|
var Prototype = {
|
14
|
-
Version: '1.4.
|
14
|
+
Version: '1.4.0',
|
15
|
+
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
|
15
16
|
|
16
17
|
emptyFunction: function() {},
|
17
18
|
K: function(x) {return x}
|
@@ -45,10 +46,10 @@ Object.inspect = function(object) {
|
|
45
46
|
}
|
46
47
|
}
|
47
48
|
|
48
|
-
Function.prototype.bind = function(
|
49
|
-
var __method = this;
|
49
|
+
Function.prototype.bind = function() {
|
50
|
+
var __method = this, args = $A(arguments), object = args.shift();
|
50
51
|
return function() {
|
51
|
-
return __method.apply(object, arguments);
|
52
|
+
return __method.apply(object, args.concat($A(arguments)));
|
52
53
|
}
|
53
54
|
}
|
54
55
|
|
@@ -143,6 +144,22 @@ Object.extend(String.prototype, {
|
|
143
144
|
return this.replace(/<\/?[^>]+>/gi, '');
|
144
145
|
},
|
145
146
|
|
147
|
+
stripScripts: function() {
|
148
|
+
return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
|
149
|
+
},
|
150
|
+
|
151
|
+
extractScripts: function() {
|
152
|
+
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
|
153
|
+
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
|
154
|
+
return (this.match(matchAll) || []).map(function(scriptTag) {
|
155
|
+
return (scriptTag.match(matchOne) || ['', ''])[1];
|
156
|
+
});
|
157
|
+
},
|
158
|
+
|
159
|
+
evalScripts: function() {
|
160
|
+
return this.extractScripts().map(eval);
|
161
|
+
},
|
162
|
+
|
146
163
|
escapeHTML: function() {
|
147
164
|
var div = document.createElement('div');
|
148
165
|
var text = document.createTextNode(this);
|
@@ -214,8 +231,8 @@ var Enumerable = {
|
|
214
231
|
all: function(iterator) {
|
215
232
|
var result = true;
|
216
233
|
this.each(function(value, index) {
|
217
|
-
|
218
|
-
|
234
|
+
result = result && !!(iterator || Prototype.K)(value, index);
|
235
|
+
if (!result) throw $break;
|
219
236
|
});
|
220
237
|
return result;
|
221
238
|
},
|
@@ -223,7 +240,7 @@ var Enumerable = {
|
|
223
240
|
any: function(iterator) {
|
224
241
|
var result = true;
|
225
242
|
this.each(function(value, index) {
|
226
|
-
if (result
|
243
|
+
if (result = !!(iterator || Prototype.K)(value, index))
|
227
244
|
throw $break;
|
228
245
|
});
|
229
246
|
return result;
|
@@ -376,6 +393,7 @@ Object.extend(Enumerable, {
|
|
376
393
|
entries: Enumerable.toArray
|
377
394
|
});
|
378
395
|
var $A = Array.from = function(iterable) {
|
396
|
+
if (!iterable) return [];
|
379
397
|
if (iterable.toArray) {
|
380
398
|
return iterable.toArray();
|
381
399
|
} else {
|
@@ -388,12 +406,19 @@ var $A = Array.from = function(iterable) {
|
|
388
406
|
|
389
407
|
Object.extend(Array.prototype, Enumerable);
|
390
408
|
|
409
|
+
Array.prototype._reverse = Array.prototype.reverse;
|
410
|
+
|
391
411
|
Object.extend(Array.prototype, {
|
392
412
|
_each: function(iterator) {
|
393
413
|
for (var i = 0; i < this.length; i++)
|
394
414
|
iterator(this[i]);
|
395
415
|
},
|
396
416
|
|
417
|
+
clear: function() {
|
418
|
+
this.length = 0;
|
419
|
+
return this;
|
420
|
+
},
|
421
|
+
|
397
422
|
first: function() {
|
398
423
|
return this[0];
|
399
424
|
},
|
@@ -425,13 +450,18 @@ Object.extend(Array.prototype, {
|
|
425
450
|
indexOf: function(object) {
|
426
451
|
for (var i = 0; i < this.length; i++)
|
427
452
|
if (this[i] == object) return i;
|
428
|
-
return
|
453
|
+
return -1;
|
429
454
|
},
|
430
455
|
|
431
|
-
reverse: function() {
|
432
|
-
|
433
|
-
|
434
|
-
|
456
|
+
reverse: function(inline) {
|
457
|
+
return (inline !== false ? this : this.toArray())._reverse();
|
458
|
+
},
|
459
|
+
|
460
|
+
shift: function() {
|
461
|
+
var result = this[0];
|
462
|
+
for (var i = 0; i < this.length - 1; i++)
|
463
|
+
this[i] = this[i + 1];
|
464
|
+
this.length--;
|
435
465
|
return result;
|
436
466
|
},
|
437
467
|
|
@@ -486,9 +516,9 @@ function $H(object) {
|
|
486
516
|
Object.extend(hash, Hash);
|
487
517
|
return hash;
|
488
518
|
}
|
489
|
-
|
490
|
-
Object.extend(
|
491
|
-
Object.extend(
|
519
|
+
ObjectRange = Class.create();
|
520
|
+
Object.extend(ObjectRange.prototype, Enumerable);
|
521
|
+
Object.extend(ObjectRange.prototype, {
|
492
522
|
initialize: function(start, end, exclusive) {
|
493
523
|
this.start = start;
|
494
524
|
this.end = end;
|
@@ -513,7 +543,7 @@ Object.extend(Range.prototype, {
|
|
513
543
|
});
|
514
544
|
|
515
545
|
var $R = function(start, end, exclusive) {
|
516
|
-
return new
|
546
|
+
return new ObjectRange(start, end, exclusive);
|
517
547
|
}
|
518
548
|
|
519
549
|
var Ajax = {
|
@@ -549,8 +579,7 @@ Ajax.Responders = {
|
|
549
579
|
if (responder[callback] && typeof responder[callback] == 'function') {
|
550
580
|
try {
|
551
581
|
responder[callback].apply(responder, [request, transport, json]);
|
552
|
-
} catch (e) {
|
553
|
-
}
|
582
|
+
} catch (e) {}
|
554
583
|
}
|
555
584
|
});
|
556
585
|
}
|
@@ -626,8 +655,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
|
|
626
655
|
this.transport.send(this.options.method == 'post' ? body : null);
|
627
656
|
|
628
657
|
} catch (e) {
|
629
|
-
|
630
|
-
Ajax.Responders.dispatch('onException', this, e);
|
658
|
+
this.dispatchException(e);
|
631
659
|
}
|
632
660
|
},
|
633
661
|
|
@@ -661,12 +689,23 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
|
|
661
689
|
this.respondToReadyState(this.transport.readyState);
|
662
690
|
},
|
663
691
|
|
692
|
+
header: function(name) {
|
693
|
+
try {
|
694
|
+
return this.transport.getResponseHeader(name);
|
695
|
+
} catch (e) {}
|
696
|
+
},
|
697
|
+
|
664
698
|
evalJSON: function() {
|
665
699
|
try {
|
666
|
-
|
667
|
-
|
668
|
-
|
700
|
+
return eval(this.header('X-JSON'));
|
701
|
+
} catch (e) {}
|
702
|
+
},
|
703
|
+
|
704
|
+
evalResponse: function() {
|
705
|
+
try {
|
706
|
+
return eval(this.transport.responseText);
|
669
707
|
} catch (e) {
|
708
|
+
this.dispatchException(e);
|
670
709
|
}
|
671
710
|
},
|
672
711
|
|
@@ -674,22 +713,38 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
|
|
674
713
|
var event = Ajax.Request.Events[readyState];
|
675
714
|
var transport = this.transport, json = this.evalJSON();
|
676
715
|
|
677
|
-
if (event == 'Complete')
|
678
|
-
|
679
|
-
|
680
|
-
|
716
|
+
if (event == 'Complete') {
|
717
|
+
try {
|
718
|
+
(this.options['on' + this.transport.status]
|
719
|
+
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
|
720
|
+
|| Prototype.emptyFunction)(transport, json);
|
721
|
+
} catch (e) {
|
722
|
+
this.dispatchException(e);
|
723
|
+
}
|
681
724
|
|
682
|
-
|
683
|
-
|
725
|
+
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
|
726
|
+
this.evalResponse();
|
727
|
+
}
|
728
|
+
|
729
|
+
try {
|
730
|
+
(this.options['on' + event] || Prototype.emptyFunction)(transport, json);
|
731
|
+
Ajax.Responders.dispatch('on' + event, this, transport, json);
|
732
|
+
} catch (e) {
|
733
|
+
this.dispatchException(e);
|
734
|
+
}
|
684
735
|
|
685
736
|
/* Avoid memory leak in MSIE: clean up the oncomplete event handler */
|
686
737
|
if (event == 'Complete')
|
687
738
|
this.transport.onreadystatechange = Prototype.emptyFunction;
|
739
|
+
},
|
740
|
+
|
741
|
+
dispatchException: function(exception) {
|
742
|
+
(this.options.onException || Prototype.emptyFunction)(this, exception);
|
743
|
+
Ajax.Responders.dispatch('onException', this, exception);
|
688
744
|
}
|
689
745
|
});
|
690
746
|
|
691
747
|
Ajax.Updater = Class.create();
|
692
|
-
Ajax.Updater.ScriptFragment = '(?:<script.*?>)((\n|.)*?)(?:<\/script>)';
|
693
748
|
|
694
749
|
Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
|
695
750
|
initialize: function(container, url, options) {
|
@@ -714,16 +769,16 @@ Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
|
|
714
769
|
updateContent: function() {
|
715
770
|
var receiver = this.responseIsSuccess() ?
|
716
771
|
this.containers.success : this.containers.failure;
|
772
|
+
var response = this.transport.responseText;
|
717
773
|
|
718
|
-
|
719
|
-
|
720
|
-
var scripts = this.transport.responseText.match(match);
|
774
|
+
if (!this.options.evalScripts)
|
775
|
+
response = response.stripScripts();
|
721
776
|
|
722
777
|
if (receiver) {
|
723
778
|
if (this.options.insertion) {
|
724
779
|
new this.options.insertion(receiver, response);
|
725
780
|
} else {
|
726
|
-
receiver
|
781
|
+
Element.update(receiver, response);
|
727
782
|
}
|
728
783
|
}
|
729
784
|
|
@@ -731,14 +786,6 @@ Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
|
|
731
786
|
if (this.onComplete)
|
732
787
|
setTimeout(this.onComplete.bind(this), 10);
|
733
788
|
}
|
734
|
-
|
735
|
-
if (this.options.evalScripts && scripts) {
|
736
|
-
match = new RegExp(Ajax.Updater.ScriptFragment, 'im');
|
737
|
-
setTimeout((function() {
|
738
|
-
for (var i = 0; i < scripts.length; i++)
|
739
|
-
eval(scripts[i].match(match)[1]);
|
740
|
-
}).bind(this), 10);
|
741
|
-
}
|
742
789
|
}
|
743
790
|
});
|
744
791
|
|
@@ -830,6 +877,11 @@ Object.extend(Element, {
|
|
830
877
|
element.parentNode.removeChild(element);
|
831
878
|
},
|
832
879
|
|
880
|
+
update: function(element, html) {
|
881
|
+
$(element).innerHTML = html.stripScripts();
|
882
|
+
setTimeout(function() {html.evalScripts()}, 10);
|
883
|
+
},
|
884
|
+
|
833
885
|
getHeight: function(element) {
|
834
886
|
element = $(element);
|
835
887
|
return element.offsetHeight;
|
@@ -893,6 +945,12 @@ Object.extend(Element, {
|
|
893
945
|
return value == 'auto' ? null : value;
|
894
946
|
},
|
895
947
|
|
948
|
+
setStyle: function(element, style) {
|
949
|
+
element = $(element);
|
950
|
+
for (name in style)
|
951
|
+
element.style[name.camelize()] = style[name];
|
952
|
+
},
|
953
|
+
|
896
954
|
getDimensions: function(element) {
|
897
955
|
element = $(element);
|
898
956
|
if (Element.getStyle(element, 'display') != 'none')
|
@@ -969,7 +1027,7 @@ Abstract.Insertion = function(adjacency) {
|
|
969
1027
|
Abstract.Insertion.prototype = {
|
970
1028
|
initialize: function(element, content) {
|
971
1029
|
this.element = $(element);
|
972
|
-
this.content = content;
|
1030
|
+
this.content = content.stripScripts();
|
973
1031
|
|
974
1032
|
if (this.adjacency && this.element.insertAdjacentHTML) {
|
975
1033
|
try {
|
@@ -986,6 +1044,8 @@ Abstract.Insertion.prototype = {
|
|
986
1044
|
if (this.initializeRange) this.initializeRange();
|
987
1045
|
this.insertContent([this.range.createContextualFragment(this.content)]);
|
988
1046
|
}
|
1047
|
+
|
1048
|
+
setTimeout(function() {content.evalScripts()}, 10);
|
989
1049
|
},
|
990
1050
|
|
991
1051
|
contentFromAnonymousTable: function() {
|
@@ -1018,7 +1078,7 @@ Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
|
|
1018
1078
|
},
|
1019
1079
|
|
1020
1080
|
insertContent: function(fragments) {
|
1021
|
-
fragments.reverse().each((function(fragment) {
|
1081
|
+
fragments.reverse(false).each((function(fragment) {
|
1022
1082
|
this.element.insertBefore(fragment, this.element.firstChild);
|
1023
1083
|
}).bind(this));
|
1024
1084
|
}
|
@@ -1079,7 +1139,7 @@ Element.ClassNames.prototype = {
|
|
1079
1139
|
if (!this.include(classNameToRemove)) return;
|
1080
1140
|
this.set(this.select(function(className) {
|
1081
1141
|
return className != classNameToRemove;
|
1082
|
-
}));
|
1142
|
+
}).join(' '));
|
1083
1143
|
},
|
1084
1144
|
|
1085
1145
|
toString: function() {
|
@@ -1109,8 +1169,10 @@ var Field = {
|
|
1109
1169
|
},
|
1110
1170
|
|
1111
1171
|
activate: function(element) {
|
1112
|
-
$(element)
|
1113
|
-
|
1172
|
+
element = $(element);
|
1173
|
+
element.focus();
|
1174
|
+
if (element.select)
|
1175
|
+
element.select();
|
1114
1176
|
}
|
1115
1177
|
}
|
1116
1178
|
|
@@ -1178,16 +1240,15 @@ var Form = {
|
|
1178
1240
|
}
|
1179
1241
|
},
|
1180
1242
|
|
1243
|
+
findFirstElement: function(form) {
|
1244
|
+
return Form.getElements(form).find(function(element) {
|
1245
|
+
return element.type != 'hidden' && !element.disabled &&
|
1246
|
+
['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
|
1247
|
+
});
|
1248
|
+
},
|
1249
|
+
|
1181
1250
|
focusFirstElement: function(form) {
|
1182
|
-
|
1183
|
-
var elements = Form.getElements(form);
|
1184
|
-
for (var i = 0; i < elements.length; i++) {
|
1185
|
-
var element = elements[i];
|
1186
|
-
if (element.type != 'hidden' && !element.disabled) {
|
1187
|
-
Field.activate(element);
|
1188
|
-
break;
|
1189
|
-
}
|
1190
|
-
}
|
1251
|
+
Field.activate(Form.findFirstElement(form));
|
1191
1252
|
},
|
1192
1253
|
|
1193
1254
|
reset: function(form) {
|
@@ -1201,9 +1262,17 @@ Form.Element = {
|
|
1201
1262
|
var method = element.tagName.toLowerCase();
|
1202
1263
|
var parameter = Form.Element.Serializers[method](element);
|
1203
1264
|
|
1204
|
-
if (parameter)
|
1205
|
-
|
1206
|
-
|
1265
|
+
if (parameter) {
|
1266
|
+
var key = encodeURIComponent(parameter[0]);
|
1267
|
+
if (key.length == 0) return;
|
1268
|
+
|
1269
|
+
if (parameter[1].constructor != Array)
|
1270
|
+
parameter[1] = [parameter[1]];
|
1271
|
+
|
1272
|
+
return parameter[1].map(function(value) {
|
1273
|
+
return key + '=' + encodeURIComponent(value);
|
1274
|
+
}).join('&');
|
1275
|
+
}
|
1207
1276
|
},
|
1208
1277
|
|
1209
1278
|
getValue: function(element) {
|
@@ -1349,24 +1418,14 @@ Abstract.EventObserver.prototype = {
|
|
1349
1418
|
switch (element.type.toLowerCase()) {
|
1350
1419
|
case 'checkbox':
|
1351
1420
|
case 'radio':
|
1352
|
-
element
|
1353
|
-
element.prev_onclick = element.onclick || Prototype.emptyFunction;
|
1354
|
-
element.onclick = function() {
|
1355
|
-
this.prev_onclick();
|
1356
|
-
this.target.onElementEvent();
|
1357
|
-
}
|
1421
|
+
Event.observe(element, 'click', this.onElementEvent.bind(this));
|
1358
1422
|
break;
|
1359
1423
|
case 'password':
|
1360
1424
|
case 'text':
|
1361
1425
|
case 'textarea':
|
1362
1426
|
case 'select-one':
|
1363
1427
|
case 'select-multiple':
|
1364
|
-
element
|
1365
|
-
element.prev_onchange = element.onchange || Prototype.emptyFunction;
|
1366
|
-
element.onchange = function() {
|
1367
|
-
this.prev_onchange();
|
1368
|
-
this.target.onElementEvent();
|
1369
|
-
}
|
1428
|
+
Event.observe(element, 'change', this.onElementEvent.bind(this));
|
1370
1429
|
break;
|
1371
1430
|
}
|
1372
1431
|
}
|
data/test/gettext_test.rb
CHANGED
@@ -238,6 +238,11 @@ DDD
|
|
238
238
|
assert_equal("language", _("language"))
|
239
239
|
setlocale("fr")
|
240
240
|
assert_equal("french", _("language"))
|
241
|
+
|
242
|
+
# Confirm to set Locale::Object.
|
243
|
+
loc = Locale::Object.new("ja_JP.eucJP")
|
244
|
+
assert_equal(loc, GetText.locale = loc)
|
245
|
+
assert_equal(Locale::Object, GetText.locale.class)
|
241
246
|
end
|
242
247
|
|
243
248
|
end
|
data/test/gettext_test_locale.rb
CHANGED
@@ -10,6 +10,9 @@ class TestLocale < Test::Unit::TestCase
|
|
10
10
|
assert_equal("ja_JP", obj.to_posix)
|
11
11
|
assert_equal("ja_JP", obj.to_str)
|
12
12
|
assert_equal("ja-JP", obj.to_iso3066)
|
13
|
+
assert_equal("ja-JP", obj.to_win)
|
14
|
+
assert_equal("ja_JP", obj.to_general)
|
15
|
+
assert_equal("ja", obj.orig_str)
|
13
16
|
assert_equal(["ja", "JP", "eucJP", nil, nil, nil], obj.to_a)
|
14
17
|
|
15
18
|
obj = Locale::Object.new("ja", "JP")
|
@@ -17,8 +20,14 @@ class TestLocale < Test::Unit::TestCase
|
|
17
20
|
assert_equal("JP", obj.country)
|
18
21
|
assert_equal(nil, obj.charset)
|
19
22
|
assert_equal(nil, obj.script)
|
20
|
-
assert_equal(nil, obj.
|
23
|
+
assert_equal(nil, obj.variant)
|
21
24
|
assert_equal(nil, obj.modifier)
|
25
|
+
assert_equal("ja_JP", obj.to_posix)
|
26
|
+
assert_equal("ja_JP", obj.to_str)
|
27
|
+
assert_equal("ja-JP", obj.to_iso3066)
|
28
|
+
assert_equal("ja-JP", obj.to_win)
|
29
|
+
assert_equal("ja_JP", obj.to_general)
|
30
|
+
assert_equal("ja", obj.orig_str)
|
22
31
|
assert_equal(["ja", "JP", nil, nil, nil, nil], obj.to_a)
|
23
32
|
|
24
33
|
obj = Locale::Object.new("ja")
|
@@ -26,8 +35,14 @@ class TestLocale < Test::Unit::TestCase
|
|
26
35
|
assert_equal(nil, obj.country)
|
27
36
|
assert_equal(nil, obj.charset)
|
28
37
|
assert_equal(nil, obj.script)
|
29
|
-
assert_equal(nil, obj.
|
38
|
+
assert_equal(nil, obj.variant)
|
30
39
|
assert_equal(nil, obj.modifier)
|
40
|
+
assert_equal("ja", obj.to_posix)
|
41
|
+
assert_equal("ja", obj.to_str)
|
42
|
+
assert_equal("ja", obj.to_iso3066)
|
43
|
+
assert_equal("ja", obj.to_win)
|
44
|
+
assert_equal("ja", obj.to_general)
|
45
|
+
assert_equal("ja", obj.orig_str)
|
31
46
|
assert_equal(["ja", nil, nil, nil, nil, nil], obj.to_a)
|
32
47
|
|
33
48
|
obj = Locale::Object.new("ja_JP.eucJP", nil, "UTF-8")
|
@@ -35,8 +50,14 @@ class TestLocale < Test::Unit::TestCase
|
|
35
50
|
assert_equal("JP", obj.country)
|
36
51
|
assert_equal("UTF-8", obj.charset)
|
37
52
|
assert_equal(nil, obj.script)
|
38
|
-
assert_equal(nil, obj.
|
53
|
+
assert_equal(nil, obj.variant)
|
39
54
|
assert_equal(nil, obj.modifier)
|
55
|
+
assert_equal("ja_JP", obj.to_posix)
|
56
|
+
assert_equal("ja_JP", obj.to_str)
|
57
|
+
assert_equal("ja-JP", obj.to_iso3066)
|
58
|
+
assert_equal("ja-JP", obj.to_win)
|
59
|
+
assert_equal("ja_JP", obj.to_general)
|
60
|
+
assert_equal("ja_JP.eucJP", obj.orig_str)
|
40
61
|
assert_equal(["ja", "JP", "UTF-8", nil, nil, nil], obj.to_a)
|
41
62
|
|
42
63
|
obj = Locale::Object.new("en-US.iso8859-1", "CA")
|
@@ -44,8 +65,14 @@ class TestLocale < Test::Unit::TestCase
|
|
44
65
|
assert_equal("CA", obj.country)
|
45
66
|
assert_equal("iso8859-1", obj.charset)
|
46
67
|
assert_equal(nil, obj.script)
|
47
|
-
assert_equal(nil, obj.
|
68
|
+
assert_equal(nil, obj.variant)
|
48
69
|
assert_equal(nil, obj.modifier)
|
70
|
+
assert_equal("en_CA", obj.to_posix)
|
71
|
+
assert_equal("en_CA", obj.to_str)
|
72
|
+
assert_equal("en-CA", obj.to_iso3066)
|
73
|
+
assert_equal("en-CA", obj.to_win)
|
74
|
+
assert_equal("en_CA", obj.to_general)
|
75
|
+
assert_equal("en-US.iso8859-1", obj.orig_str)
|
49
76
|
assert_equal(["en", "CA", "iso8859-1", nil, nil, nil], obj.to_a)
|
50
77
|
|
51
78
|
obj = Locale::Object.new("uz@Latn")
|
@@ -53,8 +80,14 @@ class TestLocale < Test::Unit::TestCase
|
|
53
80
|
assert_equal(nil, obj.country)
|
54
81
|
assert_equal(nil, obj.charset)
|
55
82
|
assert_equal(nil, obj.script)
|
56
|
-
assert_equal(nil, obj.
|
83
|
+
assert_equal(nil, obj.variant)
|
57
84
|
assert_equal("Latn", obj.modifier)
|
85
|
+
assert_equal("uz", obj.to_posix)
|
86
|
+
assert_equal("uz", obj.to_str)
|
87
|
+
assert_equal("uz", obj.to_iso3066)
|
88
|
+
assert_equal("uz", obj.to_win)
|
89
|
+
assert_equal("uz", obj.to_general)
|
90
|
+
assert_equal("uz@Latn", obj.orig_str)
|
58
91
|
assert_equal(["uz", nil, nil, nil, nil, "Latn"], obj.to_a)
|
59
92
|
|
60
93
|
obj = Locale::Object.new("zh_CN.GB2312@test")
|
@@ -62,8 +95,13 @@ class TestLocale < Test::Unit::TestCase
|
|
62
95
|
assert_equal("CN", obj.country)
|
63
96
|
assert_equal("GB2312", obj.charset)
|
64
97
|
assert_equal(nil, obj.script)
|
65
|
-
assert_equal(nil, obj.
|
98
|
+
assert_equal(nil, obj.variant)
|
66
99
|
assert_equal("test", obj.modifier)
|
100
|
+
assert_equal("zh_CN", obj.to_posix)
|
101
|
+
assert_equal("zh_CN", obj.to_str)
|
102
|
+
assert_equal("zh-CN", obj.to_iso3066)
|
103
|
+
assert_equal("zh-CN", obj.to_win)
|
104
|
+
assert_equal("zh_CN", obj.to_general)
|
67
105
|
assert_equal(["zh", "CN", "GB2312", nil, nil, "test"], obj.to_a)
|
68
106
|
|
69
107
|
obj = Locale::Object.new("wa_BE.iso885915@euro")
|
@@ -71,18 +109,101 @@ class TestLocale < Test::Unit::TestCase
|
|
71
109
|
assert_equal("BE", obj.country)
|
72
110
|
assert_equal("iso885915", obj.charset)
|
73
111
|
assert_equal(nil, obj.script)
|
74
|
-
assert_equal(nil, obj.
|
112
|
+
assert_equal(nil, obj.variant)
|
75
113
|
assert_equal("euro", obj.modifier)
|
114
|
+
assert_equal("wa_BE", obj.to_posix)
|
115
|
+
assert_equal("wa_BE", obj.to_str)
|
116
|
+
assert_equal("wa-BE", obj.to_iso3066)
|
117
|
+
assert_equal("wa-BE", obj.to_win)
|
118
|
+
assert_equal("wa_BE", obj.to_general)
|
119
|
+
assert_equal("wa_BE.iso885915@euro", obj.orig_str)
|
76
120
|
assert_equal(["wa", "BE", "iso885915", nil, nil, "euro"], obj.to_a)
|
77
121
|
|
78
|
-
obj = Locale::Object.new("
|
122
|
+
obj = Locale::Object.new("hu-HU_technl")
|
123
|
+
assert_equal("hu", obj.language)
|
124
|
+
assert_equal("HU", obj.country)
|
125
|
+
assert_equal(nil, obj.charset)
|
126
|
+
assert_equal(nil, obj.script)
|
127
|
+
assert_equal("technl", obj.variant)
|
128
|
+
assert_equal(nil, obj.modifier)
|
129
|
+
assert_equal("hu_HU", obj.to_posix)
|
130
|
+
assert_equal("hu_HU", obj.to_str)
|
131
|
+
assert_equal("hu-HU", obj.to_iso3066)
|
132
|
+
assert_equal("hu-HU", obj.to_win)
|
133
|
+
assert_equal("hu_HU", obj.to_general)
|
134
|
+
assert_equal("hu-HU_technl", obj.orig_str)
|
135
|
+
assert_equal(["hu", "HU", nil, nil, "technl", nil], obj.to_a)
|
136
|
+
|
137
|
+
obj = Locale::Object.new("uz_UZ_Latn")
|
79
138
|
assert_equal("uz", obj.language)
|
80
139
|
assert_equal("UZ", obj.country)
|
81
140
|
assert_equal(nil, obj.charset)
|
82
141
|
assert_equal("Latn", obj.script)
|
83
|
-
assert_equal(nil, obj.
|
142
|
+
assert_equal(nil, obj.variant)
|
84
143
|
assert_equal(nil, obj.modifier)
|
144
|
+
assert_equal("uz_UZ", obj.to_posix)
|
145
|
+
assert_equal("uz_UZ", obj.to_str)
|
146
|
+
assert_equal("uz-UZ", obj.to_iso3066)
|
147
|
+
assert_equal("uz-UZ-Latn", obj.to_win)
|
148
|
+
assert_equal("uz_UZ_Latn", obj.to_general)
|
149
|
+
assert_equal("uz_UZ_Latn", obj.orig_str)
|
85
150
|
assert_equal(["uz", "UZ", nil, "Latn", nil, nil], obj.to_a)
|
151
|
+
|
152
|
+
obj = Locale::Object.new("zh_Hant")
|
153
|
+
assert_equal("zh", obj.language)
|
154
|
+
assert_equal(nil, obj.country)
|
155
|
+
assert_equal(nil, obj.charset)
|
156
|
+
assert_equal("Hant", obj.script)
|
157
|
+
assert_equal(nil, obj.variant)
|
158
|
+
assert_equal(nil, obj.modifier)
|
159
|
+
assert_equal("zh", obj.to_posix)
|
160
|
+
assert_equal("zh", obj.to_str)
|
161
|
+
assert_equal("zh", obj.to_iso3066)
|
162
|
+
assert_equal("zh-Hant", obj.to_win)
|
163
|
+
assert_equal("zh_Hant", obj.to_general)
|
164
|
+
assert_equal("zh_Hant", obj.orig_str)
|
165
|
+
assert_equal(["zh", nil, nil, "Hant", nil, nil], obj.to_a)
|
166
|
+
|
167
|
+
obj = Locale::Object.new("zh_Hant_HK")
|
168
|
+
assert_equal("zh", obj.language)
|
169
|
+
assert_equal("HK", obj.country)
|
170
|
+
assert_equal(nil, obj.charset)
|
171
|
+
assert_equal("Hant", obj.script)
|
172
|
+
assert_equal(nil, obj.variant)
|
173
|
+
assert_equal(nil, obj.modifier)
|
174
|
+
assert_equal("zh_HK", obj.to_posix)
|
175
|
+
assert_equal("zh_HK", obj.to_str)
|
176
|
+
assert_equal("zh-HK", obj.to_iso3066)
|
177
|
+
assert_equal("zh-HK-Hant", obj.to_win)
|
178
|
+
assert_equal("zh_HK_Hant", obj.to_general)
|
179
|
+
assert_equal("zh_Hant_HK", obj.orig_str)
|
180
|
+
assert_equal(["zh", "HK", nil, "Hant", nil, nil], obj.to_a)
|
181
|
+
|
182
|
+
obj = Locale::Object.new("de_DE@collation=phonebook,currency=DDM")
|
183
|
+
assert_equal("de", obj.language)
|
184
|
+
assert_equal("DE", obj.country)
|
185
|
+
assert_equal(nil, obj.charset)
|
186
|
+
assert_equal(nil, obj.script)
|
187
|
+
assert_equal(nil, obj.variant)
|
188
|
+
assert_equal("collation=phonebook,currency=DDM", obj.modifier)
|
189
|
+
assert_equal("de_DE", obj.to_posix)
|
190
|
+
assert_equal("de_DE", obj.to_str)
|
191
|
+
assert_equal("de-DE", obj.to_iso3066)
|
192
|
+
assert_equal("de-DE", obj.to_win)
|
193
|
+
assert_equal("de_DE", obj.to_general)
|
194
|
+
assert_equal("de_DE@collation=phonebook,currency=DDM", obj.orig_str)
|
195
|
+
assert_equal(["de", "DE", nil, nil, nil, "collation=phonebook,currency=DDM"], obj.to_a)
|
196
|
+
|
197
|
+
obj = Locale::Object.new("C")
|
198
|
+
assert_equal("en", obj.language)
|
199
|
+
assert_equal("C", obj.orig_str)
|
200
|
+
assert_equal(["en", nil, nil, nil, nil, nil], obj.to_a)
|
201
|
+
|
202
|
+
obj = Locale::Object.new("POSIX")
|
203
|
+
assert_equal("en", obj.language)
|
204
|
+
assert_equal("POSIX", obj.orig_str)
|
205
|
+
assert_equal(["en", nil, nil, nil, nil, nil], obj.to_a)
|
206
|
+
|
86
207
|
end
|
87
208
|
|
88
209
|
def test_locale
|
@@ -115,6 +236,9 @@ class TestLocale < Test::Unit::TestCase
|
|
115
236
|
assert_equal("ja_JP", loc.to_str)
|
116
237
|
assert_equal("ja_JP", Locale.get.to_str)
|
117
238
|
assert_equal("EUC-JP", Locale.codeset)
|
239
|
+
|
240
|
+
# Confirm to set Locale::Object
|
241
|
+
assert_equal(loc, Locale.set(loc))
|
118
242
|
end
|
119
243
|
|
120
244
|
=begin
|