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

@icodesign/dolphin

v0.7.0

Published

Dolphin is an innovative, automated internationalization (i18n) service designed to integrate seamlessly into your development pipeline.

Downloads

6

Readme

Dolphin is an innovative, automated internationalization (i18n) service designed to integrate seamlessly into your development pipeline.

How it works?

Dolphin is an automation tool that helps you to localize your app/website strings. It can automatically export, translate and import strings in your projects.

The process is simple to understand:

  1. Export the strings from your project based on configuration.

  2. Translate and review the strings to the target languages using the specified translator.

  3. Import the translated strings back to your project.

Installation

Install Dolphin globally with npm/pnpm/yarn:

npm install -g @icodesign/dolphin

Check if the installation is successful by running:

dolphin --version

Usage

Dolphin requires a configuration file to desribe the translation strings and preferred options.

Here's an example of a configuration file:

baseLanguage: en
translator:
  agent: openai
  mode: interactive
localizations:
  - id: hostapp
    path: TranditionalXcodeDemo/${LANGUAGE}.lproj/Localizable.strings
    format: strings
    languages:
      - fr
      - ja
      - zh-Hans

It means that Dolphin will look for a file named Localizable.strings in the TranditionalXcodeDemo/en.lproj directory whose format is Apple Localized Strings. And then translate it to French, Japanese, and Simplified Chinese with the api translator.

For more details on how to write a configuration file, please check the Configuration section.

Translator

Dolphin defines an interface for translators to implement, which is responsible for translating source strings into target languages.

I'm still working on adding more translators. PRs are welcome!

openai

This is a local translator which uses OpenAI API to translate strings. To use this translator, you need to provide the OpenAI API key as an environment variable (OPENAI_API_KEY) or pass it to the translator with the apiKey option.

api

The api translator is a built-in translator that uses the Dolphin API (or compatible) service to translate strings. You need to provide the baseUrl to the API endpoint.

Related spec and code of the API service (using Next.js as an example) can be found in the api folder.

You can deploy the API service to your own server or managed platforms (like Vercel) and change the baseUrl to your server address.

Deploy to Vercel with a single click:

Deploy with Vercel

You can also implement your own API server if needed.

Running Dolphin

By default, Dolphin looks for a file named dolphin.yml in the current working directory.

dolphin localize

You can specify a different file with the --config option.

dolphin localize --config path/to/dolphin.yml

An interactive shell like below will guide you through the translation process.

Output Screenshot

Configuration

Configration file is a YAML file with the following structure:

baseLanguage: [required, language code]

translator:
  agent: [required, translator name]
  mode: [required, translator mode]
  .... [extra config for the translator]

globalContext: [optional, custom translation context]

localizations:
  - id: [required, string, to identify the localization]
    path: [required, path to strings]
    format: [required, string format]
    languages:
      - [required, language code]
      - [required, language code]
      ...

  - id: [required, string, to identify the localization]
    path: [required, path to strings]
    format: [required, string format]
    languages:
      - [required, language code]
      - [required, language code]
      ...

  ...

Language codes can be any commonly used ones, such as en-US, ja, es, etc. As long as it is supported by the translator.

baseLanguage

The source language of the strings, which is used to translate from.

translator

Supported translators:

  • openai: OpenAI API. You need to provide the OpenAI API key as an environment variable (OPENAI_API_KEY) or pass it to the translator with the apiKey option.
  • api: Dolphin API. You need to provide the baseUrl to the API endpoint.

Supported modes:

  • interactive: In interactive mode, after strings are translated, Dolphin will ask you to review the result to approve or ask the agent to refine. By default, this mode is not enabled.

globalContext

The context of the translation. It will be used to provide more information to the translator.

For example, if you don't want specific words to skipped, you can say "xxx is a specific term which should be translated."

id

Arbitary unique id across localizations, used to identify the specific localization in the project.

format

  • text: Plain text
  • json: JSON file, usually used in frontend apps
  • xliff: Xliff file
  • strings: Apple Localized Strings (with "key" = "value" format)
  • xloc: Xcode Localization Catalog
  • xcode: Xcode project (Using Xcode built-in localization tool to import/export strings)

path

The path to the localization file. You can use ${LANGUAGE} as the language placeholder.

For Xcode format, the path should be .xcodeproj folder.

languages

The target languages to translate to.

Examples

For more examples, please check the Examples repo.

Troubleshooting

Logs

By default, shell wil only show the major output. To see more details, you can check the log file at ~/Library/Logs/Dolphin/dolphin-[date].log. The log directory will also be printed at the top of the shell output.

Exported Strings

Dolphin will export the translated strings to the .dolphin folder in the same directory of the configuration file. You can check if the exported strings are correct there.