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

copydeck-module

v1.0.0

Published

This is the base module for all copydeck tools, the website, the CLI, and much more

Downloads

4

Readme

Copydeck-Module

Copydeck-Mobule is the node module that allow you to transform Android, IOS or i18Next ressources files into a more user friendly Csv files. The translation from any type of file to any other type of file. The easiest way to use the module is to use is command line interface command line interface

Node integration

If you want to use in you node project you can use it like this

new Translator()
        .from({fileTypeEnum})
        .readFile({readingPath})
        .to({fileTypeEnum})
        .defineDefaultLang({locale-code})
        .translate()
        .then((x) => {
            //Do something
        });

Translator is basically a builder

|Builder method|Explication|Optional| |--------------|-----------|--------| |from|The type of file between; 'Android', 'Csv', 'IOS', 'i18Next', 'universal'|No| |readFile|The path of the reading folder|Yes, must use readAs| |readAs|The json file generally build by the IO class|Yes, must use readFile| |to|The type of file between; 'Android', 'Csv', 'IOS', 'i18Next', 'universal'|No| |defineDefaultLang|In the case of a transformation into Android files the DefaultLang determine witch language will have the folder named values|Yes| |filter|The eval string use to filter what item you want to keep. If you translate from a Csv file you can filter by column name.|Yes| |translate|Return a promise with a json file with the folder structure and data|Can by remplace by translateToFile| |translateToFile|Write the folder structure and data, receive from translate and the IO|Can by remplace by translateToFile|

Adding a new FileTypeEnum

If you wish to add a new language you will need to add two convertors one that can translate your language to Universal and one to translate Universal to your language. It allow the module to be able to transform every language into any other language.

Convertor

Every Convertor class need to have a method convert(input). You have two types of convertor.

Universal to Language

This convertor will receive a array of ConversionItem and will return a json where every key is a language and it's value is a string that will be save as the file content.

Language to Universal

This convertor will receive a json with the structure or the reading folder and will return a promise of a array of ConversionItem

Universal form

The universal form is the intermediate transformation between two language. Every language know how to transform from & To ConversionItem Array.

The ConversionItem is seperate into 3 key

{
       "_ids":{
          "string":"ID-001"
       },
       "_values":{
          "en":"String #1"
       },
       "_meta":{
          "Target":"Mobile"
       }
    },

When transforming from a Csv file if the column header is ISO6391 valid it will be use as a key in the _values object.

If the column header contains _id it will by use in the _ids object. By example if you have a string_id is key value will be string.

Every other columns will be added in the _meta object where the column name is the key .

IO

The IO package contains every langugage Reader/Writer. Every IO class as 2 method read(filePath) and write(filePath). The IO job is to Read a folder and create a json with a structure of it, and also write all the file and folder structure from a json.

By example it's the AndroidIO class job to transform this

{
   "fr":"<?xml version=\"1.0\" encoding=\"utf-8\"?> </resources>",
   "en":"<?xml version=\"1.0\" encoding=\"utf-8\"?> </resources>"
}

into

+--values-fr
|   +--strings.xml
+--values-en
|   +--string.xml