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

@ember-gettext/gettext-parser

v0.10.0

Published

Parse and generate .po files.

Downloads

142

Readme

@ember-gettext/gettext-parser

Use the gettext (po) translation format to provide translations for your Ember app.

Parse gettext messages from .hbs, .js and .ts files and generate .pot and .po files from it.

These can then be translated via a translation tool of your choice, and then converted into .json files which can be deployed with your application.

Compatibility

  • Ember CLI v2.13 or above
  • Node.js v14 or above

Installation

ember install @ember-gettext/gettext-parser

Usage

Extraction

You can extract translations with ember gettext:extract. Use ember help gettext:extract to see all available options.

By default, it will extract all filed from ./app, as well as all ./addon and ./app files from any installed addon that has ember-l10n as a dependency.

You can use these configuration options:

# Use different or multiple input directories
--input-dirs ./app --input-dirs ./other-folder

# Only include files matching the given patterns.
--include-patterns templates/landing --include-patterns templates/welcome

# Exclude files matching the given patterns
--exclude-patterns mirage --exclude-patterns fixtures

# Do not extract from these addons
--skip-dependencies styleguide-addon --skip-dependencies test-addon

# Use this as the locale of messageIds (defaults to en)
--locale de

# If enabled, new and obsolete terms will be printed to the console
--print-changes

Conversion

You can convert translated .po files with ember gettext:convert. Use ember help gettext:convert to see all available options.

It will look for a file named <locale>.po in your ./translations directory and convert it into <locale>.json in the output directory (default: app/locales/<locale>.json).

For example, if you receive a German translation of your app, you should save this file under ./translations/de.po. Then, you would run ember gettext:convert --locale=de, which will generate the file ./app/locales/de.json which can be used by ember-l10n.

Alternatively, you can also leave the --locale away, to convert all locale.po files.

Available options:

# Use different input directory
--input-dir ./translations

# Use different output directory
--output-dir ./app/locales

# Convert this locale (or all, if empty)
--locale de

# Convert this specific file (provide full path, takes precedence over input-dir)
--input-file ./my-path/file.po

# Generate/update the locale map. Set to false to skip this step
--generate-map false

Generate map

You can manually generate the map for locale imports with ember gettext:generate-map. This takes a single optional argument:

# Generate for this directory
--locale-dir ./app/loclaes

By default, this will be run whenever you convert a file, but you can also run it manually.