From c493b316b1663f189f8249a111b50bbc5facb7a8 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sat, 14 Mar 2020 07:16:47 +0100 Subject: [PATCH] feat: i18n on web (#1750) * feat: add i18n to web * chore: enable es features --- .babelrc | 6 +++++- conf/default.yaml | 4 ++++ package.json | 2 +- src/api/web/index.ts | 3 ++- yarn.lock | Bin 405419 -> 405166 bytes 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.babelrc b/.babelrc index 28397a1bd..5ac54d6c3 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,7 @@ { - "presets": [["@verdaccio"]] + "presets": [["@verdaccio"]], + "plugins": [ + "@babel/plugin-proposal-optional-chaining", + "@babel/plugin-proposal-nullish-coalescing-operator" + ] } diff --git a/conf/default.yaml b/conf/default.yaml index dc3ad4083..1f33a39b7 100644 --- a/conf/default.yaml +++ b/conf/default.yaml @@ -71,3 +71,7 @@ logs: #experiments: # # support for npm token command # token: false + +# This affect the web and api (not developed yet) +#i18n: +#web: en-US diff --git a/package.json b/package.json index f0225883e..010628233 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@verdaccio/local-storage": "^9.3.4", "@verdaccio/readme": "^9.3.3", "@verdaccio/streams": "^9.3.2", - "@verdaccio/ui-theme": "^0.3.13", + "@verdaccio/ui-theme": "^1.0.0", "JSONStream": "1.3.5", "async": "3.1.1", "body-parser": "1.19.0", diff --git a/src/api/web/index.ts b/src/api/web/index.ts index b77ce1658..e0f3431e1 100644 --- a/src/api/web/index.ts +++ b/src/api/web/index.ts @@ -80,10 +80,11 @@ export default function(config, auth, storage) { const { url_prefix } = config; const uri = `${protocol}://${host}`; const base = combineBaseUrl(protocol, host, url_prefix); + const languageWeb = config?.i18n?.web ?? 'es-US'; const primaryColor = _.get(config, 'web.primary_color') ? config.web.primary_color : ''; const title = _.get(config, 'web.title') ? config.web.title : WEB_TITLE; const scope = _.get(config, 'web.scope') ? config.web.scope : ''; - const options = { uri, protocol, host, url_prefix, base, primaryColor, title, scope }; + const options = { uri, protocol, host, url_prefix, base, primaryColor, title, scope, language: languageWeb }; const webPage = template .replace(/ToReplaceByVerdaccioUI/g, JSON.stringify(options)) diff --git a/yarn.lock b/yarn.lock index c9929faba6a3e1117325c1e96c1fed5047b48a43..0d5d101814ab4bea725a8ce5248069e561e682ac 100644 GIT binary patch delta 195 zcmZ2|Ut--|iH0qVKT4->P-k?T?oh_4U|^_c0E8v!Rm!Hu<_2aaCYEU_Nk*w=W~l~d ziAF{iX67lWNye#ZsVQk@DJjX8lOO7fhoy(6rkGMX8ao zez}=frN5I!QEFk9MY%zRTbh@zho?b`V^Ll}v3EtJuW?}e?=nUpX4?L{jM?=0^aUa; VJk#ysST?nPiDlXTC6;y91pvo_O7j2!