biesbjerg / ngx-translate-extract

Extract translatable (using ngx-translate) strings and save as a JSON or Gettext pot file
MIT License
524 stars 196 forks source link

Option to add namespaces to extracted keys according to folder structure #228

Open antal-huck opened 3 years ago

antal-huck commented 3 years ago

Hi, I'm currently figuring out a good workflow to deal with the following situation:

I have a project that previously used the following pattern frequently: <span translate> This is an example text. This string wants to be added to the file *.json. </span>

Ideally, those strings are automatically identified, a suitable key gets generated, and the string inside the view/code gets replaced by the key. If the above example resides for example in src/app/view/home/login/login.component.html then the key could be "APP-NAME.HOME.LOGIN.THIS_IS_AN_EXAMPLE_TEXT_THIS_STRING_WANTS_TO_BE_ADDED_TO_THE_FILE_JSON where all colons within the string are replaced by "", spaces are replaced by underscores, and an associated folder structure is added which can also be configured.

Automatic replacement inside the code could be an option too.

Maybe I'm just thinking of a wrong workflow, but maybe this option might also be useful for other applications.