Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fixed Supported Language File 🌐 #123

Merged
merged 2 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This project ([tarkov-dev](https://github.com/the-hideout/tarkov-dev)) is a fork

We love pull requests and contributors looking to improve this project! Anything from simple spelling errors, icon updates, fixes for small css bugs or just posting issues to keep track of what needs to be done is greatly appreciated.

### Deployment 🚀
## Deployment 🚀

Deploying your changes to production is easy! Just do the following:

Expand All @@ -47,6 +47,12 @@ Deploying your changes to production is easy! Just do the following:
1. A core member of [the-hideout](https://github.com/orgs/the-hideout/teams/core-contributors) will run `.deploy` on your pull request to branch deploy your changes to production
1. If everything goes okay, your PR will be merged and your changes will be auto-deployed to production! ✨

## Updating Languages 🌐

To update the supported languages used by the site with the GraphQL API, you will need to edit the following file: [`supported-languages.json`](https://github.com/the-hideout/tarkov-dev/blob/main/src/data/supported-languages.json)

> See this [pull request](https://github.com/the-hideout/tarkov-dev/pull/123) for additional context

## Other Parts of the Ecosystem 🌎

- [Stash](https://github.com/the-hideout/stash) - The official tarkov.dev Discord bot
Expand Down
11 changes: 11 additions & 0 deletions src/data/supported-languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
"cz",
"de",
"en",
"es",
"fr",
"hu",
"ru",
"tr",
"zh"
]
11 changes: 10 additions & 1 deletion src/modules/lang-helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
// Helper function to convert an i18n language to a two digit language code
import i18n from '../i18n';
import languages from '../data/supported-languages.json';

export async function langCode() {
// Convert to two digit language code
return i18n.language.replace(/-[a-zA-Z]{2}/, "");
const langFmt = i18n.language.replace(/-[a-zA-Z]{2}/, "");

// Check if the language is supported
if (languages.includes(langFmt)) {
return langFmt;
} else {
// If the language is not supported, fall back to en
return 'en';
}
};