npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sassdoc-plugin-localization

v1.4.3

Published

Sassdoc plugin which localize your documentation

Downloads

404

Readme

Inspired and used by igniteui-angular

Build Status npm version

Localizer for Sassdoc

When using Sassdoc for API docs generation you may want to generate documentation with different languages.

By using the package you will be able to:

  1. Merge all sass declarations that needs localization in a couple of json files.
  2. Translate them.
  3. Use the updated files to build a documentation for an entire project in the desired language.

Installing

npm install sassdoc-plugin-localization --save-dev

Usage

Important notes

Please take in mind that you are running your local npm packages by npx right before the command execution. The alternative would be to install the plugin globally with -g at the end of the command. Then you won't need to use npx.

Step 1

In order to generate the json representations of each sass decalaration you will have to use one of the exposed functions which is convert. The function accepts:

  1. The retrieved data which comes from the context of Sassdoc
  2. The directory where you would like to export your jsons.

As you can see the function is using sassdoc-extras in order to group the data so that the structure of the jsons to be grouped and sorted by types.

More precisely let's say we have the following 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 $s == null {
        @return '';
    }
    //cast to string
    $s: inspect($s);
    @if str-index($s, '(') {
        // ruby sass => "(selector,)"
        @return str-slice($s, 2, -3);
    } @else {
        // libsass => "selector"
        @return str-slice($s, 1, -1);
    }
}

Which says us that we have a sass definition with name bem--selector-to-string type function and group bem. So when we pass the processed data from the Sassdoc and group it we would have the following directory structure: ./your-path/bem/function.json and this file would contains the following JSON structure:

{
    "bem--selector-to-string": {
        "description": [
            "<p>Converts a passed selector value into plain string.</p>",
            ""
        ],
        "parameters": {
            "s": {
                "description": [
                    "<p>The selector to be converted.</p>",
                    ""
                ]
            }
        }
    },
    ...
}

Step 2

Do the translations and update the text within the jsons.

Step 3

To apply the changes that you have applied in those json files you will have to use the second exported function which is render The function accepts the same arguments as the convert function:

  1. The retrieved data which comes from the context of Sassdoc
  2. The directory where your json file lives.

The function would compare and replace the generated data from the Sassdoc with the translated data from the JSONS.