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

component-intl

v0.1.0

Published

Component Approach to Internationalization

Downloads

1

Readme

Component Approach To Internationalization

The approach to build locales from different application volumes or its components or from external libraries including the application execution acceleration with minimize download time and amount of traffic by loading only the required locale. This is independent from internationalization library or framework. It is only building process and possible to choose the favorite internationalization system.

Internationalization data structure

Generalized internationalization requiremens:

  • internationalization data organized in set files where each file has the same name as locale name
  • extension of files must meet the conditions:
    • must be unique within directory tree designated to search for locale files by pattern to exclude intersetion with another non locale files for example 'intl' or 'i18n'
    • may (but not necessary) be equal extension associated with file content type
  • locale data structure in each file recommends meeting the condition:
    • all the data lie under the top-level key with name equal locale name
    • application data lie under the app key (which lies under top level key)
    • data of library component (and data of application component which may be extracted to independent package) lie under key based on domain name or based on registered package name in package repository
  • presence of another keys at top level different from locale name is not allowed, recommended using app top level key for that; this mean using of legacy locale data with code require refactoring to ensure that there is no collision

Example locale data

Example of application data structture for en locale

# application file: en.yaml (or en.intl or en.i18n)
en:
  app:
    title: The title
    content: Lorem ipsum dolor sit amet

Or for library component package may be package name based

# library file: en.yaml (or en.intl or en.i18n)
en:
  package-name:
    component:
      title: The component

or domain based

# library file: en.yaml (or en.intl or en.i18n)
en:
  org.domain:
    component:
      title: The title
  • The additional helper function or component encapsulating root of tree may be useful. There is no refactoring required if component exctraction to external library is perfomed.
  • Also same additional helper function or component is useful for some additional text preprocessing such as markdown or some else.

Flattenization

Build system may do flattenization of structure that lies under the top level local-named key to simplify using keys in code. So above structure after joining and flattenization may be like this (in yaml syntax):

# application file: en.yaml
en:
  app.title: The title
  app.content: Lorem ipsum dolor sit amet
  package-name.component.title: The component
  org.domain.component.title: The title

Implementation

The build tool designed according to this approach is implemented in the form of a plugin intl-webpack-plugin for node js webpack module bundler.

Demonstration application

To demonstarate how to it works and how to build and configure application and libraries the demonstartion application and library with minimal amount of dependencies is created. An example of an application is

The references to source code repository:

License

MIT