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

shopify-language-sync

v2.0.1

Published

Tool to synchronise a Shopify them live translation with a local translation file. This tools works for slate and themekit projects

Downloads

4

Readme

shopify-language-sync

Tool to synchronise a live Shopify translation with a local translation file.

This was created while using Slate as a base project (Note that Slate ended support in January 2020)

Installation

yarn add shopify-language-sync

Version 2 updates

When using version 2, you must pass the required flag depending of the type of Shopify theme you are working on

Themekit

You must pass a --themeConfig flag

locales-sync --themeConfig config.yml

Example

...
    "scripts": {
        ...
        "sync": "locales-sync --themeConfig config.yml --srcDir=./source/locales --destDir=./dest/locales",
        ...
    }
...

Slate

You must pass a --slateEnv flag

locales-sync --slateEnv .env

Example

...
    "scripts": {
        ...
        "sync": "locales-sync --slateEnv .env",
        ...
    }
...

Setup

You neet to have a .env file with the settings for your project, same structure as https://shopify.github.io/slate/docs/connect-to-your-store

Example .env file with minimum required information

# The myshopify.com URL to your Shopify store

SLATE_STORE={store-name}.myshopify.com

# The API password generated from a Private App

SLATE_PASSWORD=ccf7fb19ed4dc6993ac6355c0c489c7c7

# The ID of the theme you wish to upload files to

SLATE_THEME_ID=32112656003

Update your package.json scripts

...
"scripts": {
    ...
    "build": "slate-tools build && locales-sync --themeConfig config.yml --srcDir=./source/locales --destDir=./dest/locales",
    ...

How it works

Using themekit, this tool downloads your theme's locales directory to a ./tmp/locales in your project. Then updates your src translation with the content in tmp and replaces it in your destination directory.

Example using Slate

In slate, all your files are under a ./src directory. The translations are in ./src/locales

Lets say we have a directory with the following structure


-   src
    ...
    -   layout
    -   locales
        en.default.json
        es-AR.json
        fi.json
        ...

We know that the locales file can be updated by the Store owner and staff at any time. We need to get the latest translations from the live site, but at the same time we want to update the structure with the latest changes in our code.

This tool takes the ./src/locales as the translation structure and replaces any existing values stored in Shopify.

Let's say that our ./src/locales/en.default.json file looks like this

{
    general: {
        hello: 'Hello',
        thanks: 'Thanks',
    },
    test: 'Test',
    nonExistent: 'Now Exisits',
}

And the file currently in Shopify looks like this:

{
    general: {
        hello: 'Hola',
        how_are_you: 'This is deleted',
        thanks: 'Thanke',
    },
    test: 'Another test',
}

After this tool run, the final result is:

{
    general: {
        hello: 'Hola',
        thanks: 'Thanke',
    },
    test: 'Another test',
    nonExistent: 'Now Exisits',
}

Example of package.json script to build a slate project with locales sync

"scripts": {
    ...
    "build": "slate-tools build && locales-sync --slateEnv .env",
    ...
}

Arguments

If you are not using Slate or have a different folder structure you can pass the following arguments

| Argument | Description | Default | Example | | ----------- | ----------------------------- | -------------- | --------------------------- | | slateEnv | Slate environment config file | | --slateEnv .env | | themeConfig | Themekit config file | | --themekitConfig config.yml | | srcDir | Source directory | ./src/locales | | | destDir | Destination directory | ./dist/locales | |

Example of package.json script to build a themekit project with locales sync

...
"scripts": {
    ...
    "sync": "locales-sync --themeConfig config.yml --srcDir=./source/locales --destDir=./dest/locales",
    ...
}