diff --git a/README.md b/README.md index a9a1a7b1f..15d470607 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ You’ll be asked to provide the following values: * [Usage](#usage) * [Options](#options) * [Plugins](#plugins) +* [Localisations](#localisations) * [Local development](#local-development) * [Credits](#credits) * [Similar projects](#similar-projects) @@ -54,6 +55,7 @@ You’ll be asked to provide the following values: * Bookmarklet to save and share bookmarks * Publish to different content stores (GitHub and GitLab) * Support for popular static site generators (Jekyll, Hugo, 11ty) +* Localised to [different languages](#localisations) * ~~Plugin API~~ ## Install @@ -179,10 +181,10 @@ To ensure Indiekit’s endpoint can be discovered by Micropub clients (and have ### `application.locale` -The language used in the application interface. Available languages: `en` +The language used in the application interface. See the list of [supported languages](#localisations). Type: `string`\ -*Optional*, defaults to `en` +*Optional*, defaults to system language if supported, else `en` (English) ### `application.mongodbUrl` @@ -214,10 +216,10 @@ Type: `Array | URL`\ ### `publication.locale` -Your publication’s locale, this value is currently used to format dates. +Your publication’s locale. Currently used to format dates. Type: `string`\ -*Optional*, defaults to value in `application.locale` +*Optional*, defaults to `en` (English) ### `publication.me` @@ -463,6 +465,15 @@ The following endpoints are included by default: * [Jekyll](https://www.npmjs.com/package/@indiekit/preset-jekyll) * [Hugo](https://www.npmjs.com/package/@indiekit/preset-hugo) +## Localisations + +Indiekit has been localised into the following languages: + +* `en-US`: English (US) +* `de-DE`: Deutsch + +Contributions for other languages are encouraged. + ## Local development ```sh diff --git a/indiekit.config.js b/indiekit.config.js index 5bfcc7965..2873d0c14 100644 --- a/indiekit.config.js +++ b/indiekit.config.js @@ -19,7 +19,6 @@ const github = new GithubStore({ // Application settings indiekit.set('application.mongodbUrl', process.env.MONGODB_URL); -indiekit.set('application.locale', process.env.LOCALE); // Publication settings indiekit.set('publication.me', process.env.PUBLICATION_URL); diff --git a/packages/endpoint-media/controllers/files.js b/packages/endpoint-media/controllers/files.js index ef3c8f211..e9ddfccd5 100644 --- a/packages/endpoint-media/controllers/files.js +++ b/packages/endpoint-media/controllers/files.js @@ -14,7 +14,7 @@ export const filesController = publication => ({ list: async (request, response, next) => { try { response.render('files', { - title: 'Uploaded files', + title: response.__('media.files.title'), files: await publication.media.find().toArray(), parentUrl: `${publication.mediaEndpoint}/files/` }); @@ -49,7 +49,7 @@ export const filesController = publication => ({ ); response.render('file', { - parent: 'Uploaded files', + parent: response.__('media.files.title'), title: file.properties.filename, published: file.properties.published, type: file.properties['post-type'], diff --git a/packages/endpoint-media/index.js b/packages/endpoint-media/index.js index 9822143d9..44b5278bb 100644 --- a/packages/endpoint-media/index.js +++ b/packages/endpoint-media/index.js @@ -5,6 +5,7 @@ import path from 'path'; import {uploadController} from './controllers/upload.js'; import {filesController} from './controllers/files.js'; import {queryController} from './controllers/query.js'; +import {locales} from './locales/index.js'; export const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -31,10 +32,13 @@ export const MediaEndpoint = class { init(indiekitConfig) { const {application, publication} = indiekitConfig; + indiekitConfig.addLocale('de', locales.de); + indiekitConfig.addLocale('en', locales.en); + if (application.hasDatabase) { indiekitConfig.addNavigation({ href: `${this.mountpath}/files`, - text: 'Files' + text: 'media.title' }); } diff --git a/packages/endpoint-media/locales/de.js b/packages/endpoint-media/locales/de.js new file mode 100644 index 000000000..c312d6b30 --- /dev/null +++ b/packages/endpoint-media/locales/de.js @@ -0,0 +1,10 @@ +export const de = { + media: { + title: 'Dateien', + download: 'Download-Datei', + properties: 'Eigenschaften', + files: { + title: 'Hochgeladene Dateien' + } + } +}; diff --git a/packages/endpoint-media/locales/en.js b/packages/endpoint-media/locales/en.js new file mode 100644 index 000000000..cc82f636d --- /dev/null +++ b/packages/endpoint-media/locales/en.js @@ -0,0 +1,10 @@ +export const en = { + media: { + title: 'Files', + download: 'Download file', + properties: 'Properties', + files: { + title: 'Uploaded files' + } + } +}; diff --git a/packages/endpoint-media/locales/index.js b/packages/endpoint-media/locales/index.js new file mode 100644 index 000000000..48f04a099 --- /dev/null +++ b/packages/endpoint-media/locales/index.js @@ -0,0 +1,4 @@ +import {de} from './de.js'; +import {en} from './en.js'; + +export const locales = {de, en}; diff --git a/packages/endpoint-media/views/file.njk b/packages/endpoint-media/views/file.njk index 99185720a..4cfb466b5 100644 --- a/packages/endpoint-media/views/file.njk +++ b/packages/endpoint-media/views/file.njk @@ -8,10 +8,10 @@ {% elif type == "video" %}