A localization plugin for SassDoc specifically designed to work with the Ignite UI SassDoc Theme.
This plugin enables you to generate multilingual documentation for your Sass codebase by:
- Exporting all sass declarations that need localization into JSON files
- Giving you the option to translate the content in these JSON files
- Importing the translated content to build documentation in different languages
npm install sassdoc-plugin-localization --save-dev
The plugin must be configured in your SassDoc configuration file. Here's an example configuration:
{
"theme": "./node_modules/igniteui-sassdoc-theme",
"dest": "./site",
"autofill": ["throw", "content"],
"display": {
"alias": true,
"access": ["public", "private"]
},
"plugins": [
{
"name": "sassdoc-plugin-localization",
"path": "./node_modules/sassdoc-plugin-localization/dist/index.js",
"options": {
"dir": "extras",
"mode": "export"
}
}
]
}
- dir: The directory where JSON files will be exported to or imported from
- mode: Determines the plugin's operation mode
export
: Only exports the JSON files for translationimport
: Only imports and applies translations from JSON filesboth
: Performs both export and import operations. Useful for pass-through builds.
Important
This plugin is specifically designed to work with the Ignite UI SassDoc Theme.
When running SassDoc with the plugin configured in export
mode, the plugin will generate JSON files containing all the text that can be localized.
For example, given this Sass definition:
////
/// @group bem
////
/// Converts a passed selector value into plain string.
/// @access private
/// @param {String} $s - The selector to be converted.
/// @returns {String}
@function bem--selector-to-string($s) {
@if not($s) {
@return '';
}
@return string.slice(meta.inspect($s), 2, -3);
}
The plugin will generate a JSON file at ./your-path/bem/function.json
with the following structure:
{
"bem--selector-to-string": {
"description": [
"Converts a passed selector value into plain string."
],
"parameters": {
"s": {
"description": [
"The selector to be converted."
]
}
}
}
}
Translate the content in the generated JSON files to your target language(s). You can do this manually or use translation services.
Run SassDoc with the plugin configured in import
mode to generate documentation using your translated JSON files.
Tip
If you want to see this plugin in action take a look at igniteui-angular