Package to replace localised string keys with their content



I’m trying to develop a package to show localised strings instead of their id’s in the code.
kind of like how Android Studio does for string ids:

so basically there will be a strings-en.json file, and a “localize” function that is used with string keys all over the code.
so if the json file looks like this:

    new-notifications-message: "you have new notifications"

and the code looks like this

const localize = require('localize');
const newNotificationsMessage = localize('new-notifications-message');

i would like the plugin to show it like this:

const localize = require('localize');
const newNotificationsMessage = "you have new notifications";

and when i click on the text it unfolds to the actual code.

i’ve tried looking at the fold api, which does much of this out of the box, but i cant set the text it shows when folded , its always three dots.
also tried block decorations, but they take up a whole line and i want it inline.
my best bet so far was overlay decoration but it show’s the decoration on the range i want but in the line below, probably so it doesn’t hide the text its decoration which usually makes sense.

would love any advice you could provide on how to approach developing such a plugin.


Atom doesn’t provide a method to arbitrarily redraw what text is in the editor, at least as a public API. Permutations of what you’re suggesting have been proposed before, but it isn’t high on our priority list. The best that you can do right now with an out-of-the-box API are decorations or perhaps tooltips, as you’ve discovered.

There is the pigments package that draws additional elements at the end of a line of text, but it doesn’t replace text. If that is something you’re interested in, you might want to take a look at that package.