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

keystone-multilingual

v1.0.0

Published

A Multilingual Model, Sitemap, and Navigation Redirection Middleware for KeystoneJS

Downloads

2

Readme

#Keystone Multilingual

  • Under Development

An opinionated Multilingual Model, Declarative Sitemap, and Redirection Middleware for KeystoneJS

Keystone Multilingual allows for declarative site map building across localized url routes with mapping between language translations of both static page templates and db models.

###Features

  • Declarative route generation with a simple structure allowing for the definition of both static (template only) and dynamic (db model) driven routes.
  • Shared or language-suffixed template per route
  • An updated keystone.List that include language and translation fields by default allowing selection of an alternative translation id object of the same model
  • Middleware to determine redirection to localised route naming
  • Langauge detection from url
  • i18n-2 integration
  • Url building based on selected language

Current Limitations / Simplifications

Currently only supports dual languages but I dont belive this will be a tough update.

API

###keystone.List

Use keystone.List with the 'multilingual' option set to true to create a model that is langauge aware.

var Post = keystone.List('Post', {
	multilingual: true,
});

Whenever objects are created the language is specified and users can select the translation, being another model of the same type.

Saving a translation on an object automatically assigns the translation object's translation as the object you are saving. These are also automatically updated and deleted whenever these events happen.

###The Language Route Map

The primary purpose of the language route map is to specify the sitemap and all it's routes declaring different localised routes for each languauge. Hitting the langauge change will map the url to the equivalent route for the selected langauge.

The mapping of dynamic content will be stored in the database for each model created by Controllers will be responsible for doing appropriate lookups on any parameters passed in order to retrieve the correct content, redirecting again to get a clean, completely localised url.

###The Language Navigation Map

This is almost arbitrary other than the first level object keys must correlate to the languages used. Your navigation template must be aware of the structure you use and be able to read it. Switching languages will automatically grab the correct navigation and assign it to locals.navLinks

Templates

Pages can either be static (rendered jade template only), or dynamic (controller specified), this only implied by use of a controller or templates configuration.

Static pages can either specify a 'templatePrefix' to have seperate templates per language (template files suffixed '-en', or '-de', etc), or a 'sharedTemplate'. All templates have access to i18n functions which do lookups on translations listed in /locales/en.js etc, most useful for the shared templates.

So far, dynamic pages share a controller across languages.

Navigation

A separate file (routes/langNavMap.js), details the navigation structure for each available language.

Assumptions to be tested

  • Navigation need not be parallel.

Todo

  • linking language versions together in keystone
  • Notification that content is not available in alternate language? Flash message?