diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml new file mode 100644 index 00000000000..9ce9f9a19cf --- /dev/null +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -0,0 +1,78 @@ +# This action is centrally managed in https://github.com/asyncapi/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo + +# It does magic only if there is package.json file in the root of the project +name: PR testing - if Node project + +on: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + +jobs: + test-nodejs-pr: + name: Test NodeJS PR - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - if: > + !github.event.pull_request.draft && !( + (github.actor == 'asyncapi-bot' && ( + startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || + startsWith(github.event.pull_request.title, 'chore(release):') + )) || + (github.actor == 'asyncapi-bot-eve' && ( + startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || + startsWith(github.event.pull_request.title, 'chore(release):') + )) || + (github.actor == 'allcontributors[bot]' && + startsWith(github.event.pull_request.title, 'docs: add') + ) + ) + id: should_run + name: Should Run + run: echo "shouldrun=true" >> $GITHUB_OUTPUT + - if: steps.should_run.outputs.shouldrun == 'true' + name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - if: steps.should_run.outputs.shouldrun == 'true' + name: Checkout repository + uses: actions/checkout@v3 + - if: steps.should_run.outputs.shouldrun == 'true' + name: Check if Node.js project and has package.json + id: packagejson + run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT + shell: bash + - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock version + uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master + id: lockversion + - if: steps.packagejson.outputs.exists == 'true' + name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "${{ steps.lockversion.outputs.version }}" + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' + name: Install dependencies + id: first-installation + run: npm install --loglevel verbose + continue-on-error: true + - if: steps.first-installation.outputs.status == 'failure' && steps.packagejson.outputs.exists == 'true' + name: Clear NPM cache and install deps again + run: | + npm cache clean --force + npm install --loglevel verbose + - if: steps.packagejson.outputs.exists == 'true' + name: Test + run: npm test --if-present + - if: steps.packagejson.outputs.exists == 'true' + name: Run linter + run: npm run lint --if-present + - if: steps.packagejson.outputs.exists == 'true' + name: Run release assets generation to make sure PR does not break it + run: npm run generate:assets --if-present diff --git a/ADDING_TRANSLATIONS.md b/ADDING_TRANSLATIONS.md new file mode 100644 index 00000000000..e4a26f9fefb --- /dev/null +++ b/ADDING_TRANSLATIONS.md @@ -0,0 +1,314 @@ +# Adding Translations to AsyncAPI Website + +We appreciate your valuable contributions to the AsyncAPI website, whether it's adding or improving existing translations. + +## Table of contents +- [Improving existing translations:](#improving-existing-translations) +- [Adding translations to a partially localized page:](#adding-translations-to-a-partially-localized-page) +- [Adding translations to a new page:](#adding-translations-to-a-new-page) +- [Adding a new locale:](#adding-a-new-locale) + +## Improving existing translations + +To modify or improve existing translations, simply navigate to the `locales` folder and edit the appropriate `JSON` files for your preferred language. + +Here is an example directory structure for the `locales` folder. It contains sub-folders named after different languages, each of which contains `JSON` files with key-value pairs for translations. + +The file `common.json` contains common translation keys such as buttons and CTAs. The other JSON files are specific to certain pages on the website. For instance, `tools.json` includes translations for all the tools-related pages on the website. + +``` +📦locales + ┣ 📂de + ┃ ┣ 📜common.json + ┃ ┣ 📜landing-page.json + ┃ ┗ 📜tools.json + ┃ ┗ 📜....json + ┗ 📂en + ┃ ┣ 📜common.json + ┃ ┣ 📜landing-page.json + ┃ ┗ 📜tools.json + ┃ ┗ 📜....json +``` + +To modify a `Landing Page`'s heading: +- Navigate to the `locales` folder. +- Select a language, e.g. `de` (German) - go to the `de` folder. +- Open `landing-page.json`. +- Change the values according to your needs. +- Create a pull request with the changes. + +## Adding translations to a partially localized page + +The text on any given page may not have a translation available in your language. + +Use the translation hook with the key specified in the `locales` folder. + +Suppose the Landing Page has a button that is still in English when the language is set to German: +- Navigate to the file where the component is defined. +- Import the `useTranslation` hook from `lib/i18n`. +- Extract the translation function from the hook `const { t } = useTranslation();`. +- Use it to pass the key of the required translation value. Make sure to add the required key to the `locales` folder according to the page's scope. In this example, we are adding translation for a button, since all translation keys related to buttons need to be specified in `common.json`. + +Example: + +`ICSFileButton.js` +```diff +... ++ import { useTranslation } from '../../lib/i18n'; + +export default function ICSFButton({ +- text = 'Download ICS File', ++ text = 'icsFileBtn', + ... +}) { + ++ const { t } = useTranslation('common'); + + return ( +