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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@enterprise_search/translation

v0.8.66

Published

Moves between language file formats

Downloads

990

Readme

Translation Software

This package provides a framework for handling multi-language translations in projects. It supports loading and saving translation files in both JSON and CSV formats, validating configuration, and checking mismatches between translations.


Installation

npm install "@enterprise_search/translation"

Or if you want it from the command line

npm install -g "@enterprise_search/indexer"

From the command line

This requires a config file in the name

npm install -g "@enterprise_search/indexer"

index experiment translation-init         # Createsan example translation.yaml file. 
                                          # Gives instructions on where files should be placed

index experiment translation              # Turns csv files into json files
index experiment translation --invert     # Turns json files into csv files
index experiment translation --help       # For more information 

Features

  • Converts a csv file with langauges for columns into json suitable for i18n
  • Can 'invert' the process to convert json files into csv files. This is useful if you have existing json files you want to consolidate and manage better
  • Error Handling: Returns validation and processing errors, while 'doing as much as it can'
  • Mismatch detection: checks for mismatchs across languages... places where something is defined in one language but not in another.

Important Files and Modules

config/config.ts

Holds the type definitions for the core entities:

  • TranslationConfig: Describes the configuration for translations.
  • CsvFilesDescription and JsonFilesDescription: Define the source and target file structures.
  • Contains helper methods:
  • validateTranslationConfig(config: TranslationConfig): Validates the configuration.
  • invertTranslationConfig(config: TranslationConfig): Switches the source and target for reverse operations.

translate.ts

Core functions for performing translations:

  • translateAllLanguageFiles: Translates all specified files in a configuration.
  • _translateOneLanguageFile: Translates a single file, returning any errors or mismatches.

loaders and savers

  • loadCsvLanguageFile: Loads translations from CSV files.
  • saveCsvLanguageFile: Saves translations to CSV files.
  • loadJsonLanguageFiles: Loads translations from JSON files.
  • saveJsonLanguageFile: Saves translations to JSON files.

Example Usage

Sample Configuration: by default in a file called translation.yaml

source: # This is the source of truth for the language files
  type: csv
  directory: sample.translation/csv/{file}.csv  # Note the {file} placeholder. Change this to your directory structure.
  pathFieldName: path

target: # This is where we put the generated language files.
  type: json
  directory: sample.translation/json/{file}/{language}.json # Note the {file} and {language} placeholders. Change this to your directory structure.

languages: # This is the list of languages we want to generate
  - de
  - en

languageFiles: # And for each language, we want to generate these files
  - about-us
  - room-booking
  - translation```

Translation Workflow

async function runTranslation(config: TranslationConfig) {
  // Validate configuration
  const validate = defaultTranslationOperations.validateTranslationConfig(config);

  if (hasErrors(validate)) {
    console.error('Configuration errors:', validate);
    return;
  }

  // Perform translations
  try {
    const errors = await translateAllLanguageFiles(defaultTranslationOperations, config);
    if (errors.length) {
      console.error('Translation errors:', errors);
    } else {
      console.log('Translations completed successfully!');
    }
  } catch (error) {
    console.error('Unexpected error:', error.message);
  }
}

runTranslation(config);

License

MIT License. See the LICENSE.md file for more details.

ChatGPT session

This is the session where we wrote the software. https://chatgpt.com/share/674b0a46-f4e4-8013-9869-4ccd016a0209