Skip to content
Snippets Groups Projects
Commit 6f116bf6 authored by Soliman Harkas's avatar Soliman Harkas
Browse files

Issue #3302462 Clean up the readme

parent 06002640
No related branches found
No related tags found
1 merge request!11Issue #3302462 Clean up the readme
# String
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`.
......@@ -87,7 +91,8 @@ drupal.core.node.search_result_summary:
msgid_plural: '@count items found'
```
After clearing the cache, you can start using `t('s:dashboard.welcome_message.short')` and so on.
After clearing the cache, you can start using
`t('s:dashboard.welcome_message.short')` and so on.
## Admin interface
......@@ -95,17 +100,21 @@ After clearing the cache, you can start using `t('s:dashboard.welcome_message.sh
Export form is located at `/admin/config/regional/translate/string-export`.
It can also be accessed through,
"Configuration" >> "Regional and language" >> "User interface translation" >> "String Export".
"Configuration" >> "Regional and language" >> "User interface translation"
>> "String Export".
You may have to provide `manage string export` permission to the users for doing this.
You may have to provide `manage string export` permission to the users
for doing this.
### Importing translation file (i.e. PO files)
You can use the interface provided by locale module to import custom translation files.
You can use the interface provided by locale module to import custom
translation files.
This is located at `/admin/config/regional/translate/import`
It can also be accessed through,
"Configuration" >> "Regional and language" >> "User interface translation" >> "Import".
"Configuration" >> "Regional and language" >> "User interface translation"
>> "Import".
## Compatible with
......@@ -116,13 +125,13 @@ It can also be accessed through,
### string_demo
Enable `string_demo` to see how definitions in `string_demo.string.yml` gets converted to string item.
Enable `string_demo` to see how definitions in `string_demo.string.yml`
gets converted to string item.
You can also check few test cases displayed at `/admin/config/string_demo/test`
### string_tmgmt
Enable `string_tmgmt` to integrate with `tmgmt` module.
This exposes an interface to exclusively browse for strings exposed via string plugin.
This exposes an interface to exclusively browse for strings exposed
via string plugin.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment