Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkdev committed Feb 20, 2022
2 parents cfffb13 + a43751c commit c34e58c
Show file tree
Hide file tree
Showing 11 changed files with 1,124 additions and 1,155 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Expand Up @@ -19,6 +19,7 @@ jobs:
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd nightly
- run: npm run pkg-upgrade
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -121,6 +121,7 @@ npm-debug.log

# App #
#######
.env
/app/configs/config.js
/app/configs/config.ts
/app/configs/config.json
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
@@ -1,13 +1,17 @@
# v2.0.6 (January 16, 2022)
# v2.0.2 (February 21, 2022)

- Fix: CI/CD
- Refactor: CI/CD now update the version of the package to the latest (nightly)

<!-- all-shields/sponsors-badges:START -->

[![Donate Paypal](https://img.shields.io/badge/donate-paypal-005EA6.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/ptkdev) [![Donate Ko-Fi](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ptkdev) [![Donate Github Sponsors](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?style=for-the-badge&logo=github)](https://github.com/sponsors/ptkdev) [![Donate Patreon](https://img.shields.io/badge/donate-patreon-F87668.svg?style=for-the-badge&logo=patreon)](https://www.patreon.com/join/ptkdev) [![Donate Bitcoin](https://img.shields.io/badge/BTC-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?style=flat-square&logo=bitcoin)](https://ptk.dev/img/icons/menu/bitcoin_wallet.png) [![Donate Ethereum](https://img.shields.io/badge/ETH-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?style=flat-square&logo=ethereum)](https://ptk.dev/img/icons/menu/ethereum_wallet.png)

<!-- all-shields/sponsors-badges:END -->

# v2.0.1 (January 16, 2022)

- Fix: CI/CD

# v2.0.0 (January 16, 2022)

- Refactor: code quality, scripts and interfaces
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -2,7 +2,7 @@

<!-- all-shields/header-badges:START -->

[![v2.0.1](https://img.shields.io/badge/version-v2.0.1-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev-boilerplate/node-cli-boilerplate/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/node-cli-boilerplate?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/node-cli-boilerplate) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev-boilerplate/node-cli-boilerplate/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
[![v2.0.2-beta.1](https://img.shields.io/badge/version-v2.0.2--beta.1-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev-boilerplate/node-cli-boilerplate/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/node-cli-boilerplate?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/node-cli-boilerplate) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev-boilerplate/node-cli-boilerplate/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)

<!-- all-shields/header-badges:END -->

Expand Down Expand Up @@ -85,7 +85,7 @@ Thanks to all our backers! 🙏 Donate 3$ or more on [paypal](https://www.paypal

## 👨‍💻 Contributing

I ❤️ contributions! I will happily accept your pull request! (**IMPORTANT**: Only nightly branch!) Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file.
I ❤️ contributions! I will happily accept your pull request! (**IMPORTANT**: Only to nightly branch!) Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file.

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Expand Down
18 changes: 9 additions & 9 deletions app/configs/config.js.tpl
@@ -1,14 +1,14 @@
module.exports = {
server: {
// http://localhost:[PORT]
port: process.env.PORT || 5000,
port: 5000,
},

// Default language
language: process.env.LANGUAGE || "en",
language: "en",

// Debug
debug: process.env.DEBUG || true,
debug: "disabled",

// LOGS
// See: https://github.com/ptkdev/ptkdev-logger
Expand All @@ -19,12 +19,12 @@ module.exports = {
},
language: "en",
colors: true,
debug: process.env.LOGGER || "enabled",
info: process.env.LOGGER || "enabled",
warning: process.env.LOGGER || "enabled",
error: process.env.LOGGER || "enabled",
sponsor: process.env.LOGGER || "enabled",
write: process.env.LOGGER_WRITE || false,
debug: "enabled",
info: "enabled",
warning: "enabled",
error: "enabled",
sponsor: "enabled",
write: false,
type: "log",
},
};
2 changes: 1 addition & 1 deletion app/routes/translations.ts
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Translations
* =====================
Expand All @@ -12,6 +11,7 @@
import en from "@translations/en.json";
import it from "@translations/it.json";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const translations: any = {
en,
it,
Expand Down
19 changes: 12 additions & 7 deletions app/translations/translate.ts
Expand Up @@ -14,8 +14,8 @@ import type { TranslateParamsInterface } from "@app/types/translate.interfaces";
/**
* Replace Params
* =====================
* If translation text is: hi {{name}} how are you?
* This function replace {{name}} token with correct value
* If translation text is: hi {name} how are you?
* This function replace {name} token with correct value
*
* @param {string} text - text of current phrase to translate (mandatory)
* @param {Object} language_params - object with token to replace, example: {name:"alex"} (mandatory)
Expand All @@ -36,22 +36,26 @@ const replaceParams = (text: string, language_params: TranslateParamsInterface):
* =====================
* Check if exist translation in selected language, if not exist get string of phrase from "en" translation
*
* @param {string} lang - language from group/user (mandatory)
* @param {string} language_id - key of translation phrase from /translations/*.json (mandatory)
*
* @return {string} text - text of available translation
*
*/
const check = (language_id: string): string => {
return translations[configs.language] && translations[configs.language][language_id]
? translations[configs.language][language_id]
: translations["en"][language_id];
const check = (lang: string, language_id: string): string => {
return (
translations?.[lang]?.[language_id] ??
translations?.["en"]?.[language_id] ??
`translation id: ${language_id} in ${lang}.json is undefined`
);
};

/**
* Translate
* =====================
* Get correct translation
*
* @param {string} lang - language from group/user (mandatory)
* @param {string} language_id - key of translation phrase from /translations/*.json (mandatory)
* @param {Object} language_params - object with token to replace, example: {name:"alex"} (optional)
*
Expand All @@ -60,7 +64,8 @@ const check = (language_id: string): string => {
*/
const translate = (language_id: string, language_params?: TranslateParamsInterface): string => {
let text = "";
text = check(language_id);

text = check(configs.language, language_id);
if (language_params) {
text = replaceParams(text, language_params);
}
Expand Down

0 comments on commit c34e58c

Please sign in to comment.