In a JSON file, allow references to other keys
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ x ] feature request
Current behavior
Today, we can only set strings and variables like {{myVar}}. It would be great to be able to include other existing keys (like a partial translation).
Expected/desired behavior
{
"greetings":"Hi",
"text":"[greetings] from Github!",
"text2":"[greetings] there!"
}
myService.get('text').subscribe(
(value) => {
console.log(value);
// Hi, from Github!
}
);
What is the motivation / use case for changing the behavior?
Today, we have to concatenate the translations on our side:
myService.get(['greetings', 'text']).subscribe(
(translations) => {
console.log(translations.greetings + ' ' + translations.text);
}
);
Issue Analytics
- State:
- Created 7 years ago
- Reactions:16
- Comments:7
Top Results From Across the Web
How to use JSON references ($refs) - Redocly
OpenAPI allows for using JSON Reference objects. JSON References are required to accomplish: a multi-file structure; re-use of schemas or ...
Read more >JSON Reference — JSON Spec documentation - Read the Docs
JSON Reference allows a JSON value to reference another value in a JSON document. This module implements utilities for exploring these objects.
Read more >Accessing a JSON value that references another JSONs key
My problems start when I try to make the doing object as a JSON file as it requires the value sprite to be...
Read more >Working with JSON - Learn web development | MDN
Other notes · JSON is purely a string with a specified data format — it contains only properties, no methods. · JSON requires...
Read more >JSON Syntax - W3Schools
JSON names require double quotes. JSON - Evaluates to JavaScript Objects. The JSON format is almost identical to JavaScript objects. In JSON, keys...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t see any valid reason to do that. Just repeat the
Hi
and make it inline. This would just add complexity to the library without a real benefit imo.This can be easily implemented via a TranslateCompiler (see ngx-translate documentation on how to register it). We are using this simple implementation:
Please be aware of the following problems you might face with this very simplistic implementation: