Fix namespaced-json compiler not preserving numeric values. Fixes #28
This commit is contained in:
parent
7654397bb3
commit
ff1c91010e
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@biesbjerg/ngx-translate-extract",
|
"name": "@biesbjerg/ngx-translate-extract",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"description": "Extract strings from projects using ngx-translate",
|
"description": "Extract strings from projects using ngx-translate",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@ -8,7 +8,9 @@ export class NamespacedJsonCompiler implements CompilerInterface {
|
|||||||
public extension = 'json';
|
public extension = 'json';
|
||||||
|
|
||||||
public compile(collection: TranslationCollection): string {
|
public compile(collection: TranslationCollection): string {
|
||||||
const values: {} = flat.unflatten(collection.values);
|
const values: {} = flat.unflatten(collection.values, {
|
||||||
|
object: true
|
||||||
|
});
|
||||||
return JSON.stringify(values, null, '\t');
|
return JSON.stringify(values, null, '\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,4 +35,14 @@ describe('NamespacedJsonCompiler', () => {
|
|||||||
expect(result).to.equal('{\n\t"NAMESPACE": {\n\t\t"KEY": {\n\t\t\t"FIRST_KEY": "",\n\t\t\t"SECOND_KEY": "VALUE"\n\t\t}\n\t}\n}');
|
expect(result).to.equal('{\n\t"NAMESPACE": {\n\t\t"KEY": {\n\t\t\t"FIRST_KEY": "",\n\t\t\t"SECOND_KEY": "VALUE"\n\t\t}\n\t}\n}');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should preserve numeric values on compile', () => {
|
||||||
|
const collection = new TranslationCollection({
|
||||||
|
"option.0": '',
|
||||||
|
"option.1": '',
|
||||||
|
"option.2": ''
|
||||||
|
});
|
||||||
|
const result: string = compiler.compile(collection);
|
||||||
|
expect(result).to.equal('{\n\t"option": {\n\t\t"0": "",\n\t\t"1": "",\n\t\t"2": ""\n\t}\n}');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user