Skip to content

Commit de643a0

Browse files
committed
Specify config where necessary, and remove where ember-i18n provides defaults.
[ci skip] [#LEI-348]
1 parent 31ad0d8 commit de643a0

File tree

9 files changed

+74
-94
lines changed

9 files changed

+74
-94
lines changed

NOTICE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ISP uses some third-party code.
2+
3+
4+
locale-utils adapted from ember-i18n internals code
5+
====================================================
6+
## Copyright and license
7+
8+
Copyright 2011 James A. Rosen
9+
10+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations under the License.

app/locales/bg/config.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// for a locale or define behavior for a locale that Ember-I18n
44
// doesn't know about.
55
export default {
6-
// rtl: [true|FALSE],
7-
//
8-
// pluralForm: function(count) {
9-
// if (count === 0) { return 'zero'; }
10-
// if (count === 1) { return 'one'; }
11-
// if (count === 2) { return 'two'; }
12-
// if (count < 5) { return 'few'; }
13-
// if (count >= 5) { return 'many'; }
14-
// return 'other';
15-
// }
6+
rtl: false,
7+
8+
pluralForm: function (count) {
9+
if (count === 0) { return 'zero'; }
10+
if (count === 1) { return 'one'; }
11+
if (count === 2) { return 'two'; }
12+
if (count < 5) { return 'few'; }
13+
if (count >= 5) { return 'many'; }
14+
return 'other';
15+
}
1616
};

app/locales/de/config.js

-16
This file was deleted.

app/locales/en/config.js

-16
This file was deleted.

app/locales/he/config.js

-16
This file was deleted.

app/locales/id/config.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// for a locale or define behavior for a locale that Ember-I18n
44
// doesn't know about.
55
export default {
6-
// rtl: [true|FALSE],
7-
//
8-
// pluralForm: function(count) {
9-
// if (count === 0) { return 'zero'; }
10-
// if (count === 1) { return 'one'; }
11-
// if (count === 2) { return 'two'; }
12-
// if (count < 5) { return 'few'; }
13-
// if (count >= 5) { return 'many'; }
14-
// return 'other';
15-
// }
6+
rtl: false,
7+
8+
pluralForm: function (count) {
9+
if (count === 0) { return 'zero'; }
10+
if (count === 1) { return 'one'; }
11+
if (count === 2) { return 'two'; }
12+
if (count < 5) { return 'few'; }
13+
if (count >= 5) { return 'many'; }
14+
return 'other';
15+
}
1616
};

app/locales/test/config.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// for a locale or define behavior for a locale that Ember-I18n
44
// doesn't know about.
55
export default {
6-
// rtl: [true|FALSE],
7-
//
8-
// pluralForm: function(count) {
9-
// if (count === 0) { return 'zero'; }
10-
// if (count === 1) { return 'one'; }
11-
// if (count === 2) { return 'two'; }
12-
// if (count < 5) { return 'few'; }
13-
// if (count >= 5) { return 'many'; }
14-
// return 'other';
15-
// }
6+
rtl: false,
7+
8+
pluralForm: function (count) {
9+
if (count === 0) { return 'zero'; }
10+
if (count === 1) { return 'one'; }
11+
if (count === 2) { return 'two'; }
12+
if (count < 5) { return 'few'; }
13+
if (count >= 5) { return 'many'; }
14+
return 'other';
15+
}
1616
};

app/locales/zh/config.js

-16
This file was deleted.

app/utils/locale-utils.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Utilities for working with ember-i18n locales
3+
*
4+
* Pulled from ember-i18n internals, which do not expose these functions directly
5+
*
6+
*/
7+
8+
9+
// Walk up configuration objects from most specific to least.
10+
function walkConfigs(id, owner) {
11+
const appConfig = owner._lookupFactory(`locale:${id}/config`);
12+
if (appConfig) { return appConfig; }
13+
14+
const addonConfig = owner._lookupFactory(`ember-i18n@config:${id}`);
15+
if (addonConfig) { return addonConfig; }
16+
17+
const parentId = parentLocale(id);
18+
if (parentId) { return walkConfigs(parentId, owner); }
19+
}
20+
21+
function parentLocale(id) {
22+
const lastDash = id.lastIndexOf('-');
23+
return lastDash > 0 ? id.substr(0, lastDash) : null;
24+
}
25+
26+
27+
export {walkConfigs};

0 commit comments

Comments
 (0)