Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ import {
classify,
dasherize,
decamelize,
underscore
underscore,
w,
loc,
} from '@ember/string'
```

Expand Down
46 changes: 0 additions & 46 deletions addon/helpers/loc.ts

This file was deleted.

57 changes: 0 additions & 57 deletions addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@module @ember/string
*/
import Cache from './cache';
import { deprecate } from '@ember/debug';

// STATE within a module is frowned upon, this exists
// to support Ember.STRINGS but shield ember internals from this legacy global
Expand Down Expand Up @@ -80,62 +79,6 @@ const DECAMELIZE_CACHE = new Cache<string, string>(1000, str =>
str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase()
);

function _fmt(str: string, formats: any[]) {
// first, replace any ORDERED replacements.
let idx = 0; // the current index for non-numerical replacements
return str.replace(/%@([0-9]+)?/g, (_s: string, argIndex: string) => {
let i = argIndex ? parseInt(argIndex, 10) - 1 : idx++;
let r = i < formats.length ? formats[i] : undefined;
return typeof r === 'string' ? r : r === null ? '(null)' : r === undefined ? '' : String(r);
});
}

/**
Formats the passed string, but first looks up the string in the localized
strings hash. This is a convenient way to localize text. See
`fmt` for more information on formatting.

Note that it is traditional but not required to prefix localized string
keys with an underscore or other character so you can easily identify
localized strings.

```javascript
import { setStrings, loc } from '@ember/string';

setStrings({
'_Hello World': 'Bonjour le monde',
'_Hello %@ %@': 'Bonjour %@ %@'
});

loc("_Hello World"); // 'Bonjour le monde';
loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith";
```

@method loc
@param {String} str The string to format
@param {Array} formats Optional array of parameters to interpolate into string.
@return {String} formatted string
@public
*/
export function loc(str: string, formats: any[]): string {
deprecate(
'loc is deprecated, use an internationalization or localization addon instead.',
false,
{
id: 'ember-string-loc',
until: '2.0.0',
// @ts-ignore requires https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32538 to be merged
url: 'http://emberjs.com/deprecations/v2.x#toc_ember-string-loc'
}
);
if (!Array.isArray(formats) || arguments.length > 2) {
formats = Array.prototype.slice.call(arguments, 1);
}

str = STRINGS[str] || str;
return _fmt(str, formats);
}

/**
Splits a string into separate units separated by spaces, eliminating any
empty strings in the process. This is a convenience method for split that
Expand Down
1 change: 0 additions & 1 deletion app/helpers/loc.ts

This file was deleted.

2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(defaults) {
'ember-cli-babel': {
emberModulesAPIPolyfillBlacklist: {
['@ember/string']: [
'fmt', 'loc', 'w',
'fmt', 'w',
'getStrings', 'setStrings',
'decamelize', 'dasherize', 'camelize',
'classify', 'underscore', 'capitalize',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"ember-load-initializers": "^2.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.5.1",
"ember-qunit-assert-helpers": "^0.2.2",
"ember-resolver": "^5.2.1",
"ember-source": "~3.10.2",
"ember-source-channel-url": "^1.1.0",
Expand Down
17 changes: 0 additions & 17 deletions tests/integration/helpers/loc-test.ts

This file was deleted.

17 changes: 1 addition & 16 deletions tests/typings/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
camelize, capitalize, classify, dasherize,
decamelize, fmt, getStrings, loc, setStrings,
decamelize, fmt, getStrings, setStrings,
underscore, w
} from "../../index";

Expand All @@ -12,21 +12,6 @@ function testFmt() {
fmt('%@', 'John');
}

function testLoc() {
let oldStrings = getStrings();
setStrings({
'_Hello World': 'Bonjour le monde',
'_Hello %@': 'Bonjour %@',
'_Hello %@ %@': 'Bonjour %@ %@',
'_Hello %@# %@#': 'Bonjour %@2 %@1'
});

loc("_Hello World"); // 'Bonjour le monde';
loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith";
loc('_Hello %@', 'John');
loc('_Hello %@ %@', ['John'], 'Doe');
}

function testW() {
w("alpha beta gamma").forEach(function(key) {
console.log(key);
Expand Down
47 changes: 0 additions & 47 deletions tests/unit/loc_test.js

This file was deleted.

Loading