Skip to content

Commit c77c690

Browse files
authored
Merge pull request #5528 from vuestorefront/i18n-tests-module-docs
added information about tests and i18n in modules
2 parents 65548b0 + 3ec4b3f commit c77c690

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [1.13.0] - UNRELEASED
99

10+
### Added
11+
- Added information about i18n & Unit tests in modules to docs - @lukaszjedrasik (#4991)
12+
1013
### Fixed
1114
- Fixed some typo in docs (#5071)
1215

docs/guide/cookbook/module.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,3 +831,29 @@ Inside `check` we tell the filter to just be applied if the attribute is named e
831831
Inside `filter` we extend the Elasticsearch query-chain by our desired filters, using the `bodybuilder` library syntax.
832832
833833
That's it, now we are able to filter by a complex query in only one line inside VSF.
834+
835+
## 7. Working with translations in module
836+
837+
Translations are provided in `core/i18n/resource/i18n/{your-locale}.csv` file and can be extended or overridden in `src/modules/{my-module}/resource/i18n/{your-locale}.csv` accordingly, but translations from `src/themes/{my-theme}/resource/i18n` have a bigger priority than translations from `src/module/{my-module}/resource/i18n`.
838+
839+
### Example
840+
841+
Here's an example of `en-US.csv` for `en-US` locale:
842+
843+
```csv
844+
"customMessage","Here is the core message that can be overwritten in the module"
845+
```
846+
847+
When you create the `en-US.csv` file within your `src/modules/{my-module}/resource/i18n/` folder and override some messages like:
848+
849+
```csv
850+
"customMessage","You can define or override translation messages here."
851+
```
852+
853+
... you may expect that `$t('customMessage')` will return `You can define or override translation messages here.` instead of `Here is the core message. that can be overwritten in the module`.
854+
855+
## 8. Tests in module
856+
857+
Our jest config allows you to write tests for each module which you have created.
858+
859+
To create a test, you have to create a file inside `src/modules/{my-module}/test/unit/`. The file has to end with `.spec.ts` or `.spec.js`. Generally, it has to match this pattern: `src/modules/{my-module}/test/unit/{my-test}.spec.(js|ts)`.

0 commit comments

Comments
 (0)