Provides a developer friendly way for managing strings in your project.
Instead of hard-coding the actual string all over your codebase, this module enables you
to add some unique string identifiers.
Instead of hard-coding the actual string all over your codebase, this
module enables you to add some unique string identifiers.
## Sample usage
...
...
@@ -19,19 +19,21 @@ NOTE: String IDs are namespaced with a prefix `s:` by design.
- Makes your codebase independent of translation workflow.
- No need to update your codebase to edit strings
- Editing a text in original language won't invalidate the translation in other language.
- Editing a text in original language won't invalidate the translation in
other language.
- More intuitive use of translation context.
- Instead of reference to codebase and source files, strings are managed via unique human friendly string "ids".
- Instead of reference to codebase and source files, strings are managed via
unique human friendly string "ids".
## Defining strings
Before you can start using "identifiers", we need to tell Drupal about it. For this,
after enabling the module, define your strings in a custom module via`string` yaml plugin.
This is similar to creating routes via routing.yml plugin.
Before you can start using "identifiers", we need to tell Drupal about it. For
this, after enabling the module, define your strings in a custom module via
`string` yaml plugin. This is similar to creating routes via routing.yml plugin.
Let say you have a module named `foo`, then create a file in the root of your module folder
called `foo.string.yml`. Each entry would represent a unique string.
Please refer to sample configuration file with ample comment.
Let say you have a module named `foo`, then create a file in the root of your
module folder called `foo.string.yml`. Each entry would represent a unique
string. Please refer to sample configuration file with ample comment.
Strings are logically grouped using `.` (a period) in their identifier.
...
...
@@ -39,7 +41,9 @@ Example `dashboard.welcome_message.short` would be part of following groups,
-`dashboard`
-`dashboard.welcome_message`
The top level group is called `namespace`. Usually this would be the module's machine name, but not necessarily. The identifier thus follows a format `namespace.key`. Where `key` can also have its own grouping.
The top level group is called `namespace`. Usually this would be the module's
machine name, but not necessarily. The identifier thus follows a format
`namespace.key`. Where `key` can also have its own grouping.
NOTE: String IDs MUST have a `namespace` and a `key`.