Skip to content

Commit

Permalink
i18l Refactoring: use proper json files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgt-Imalas committed Nov 13, 2024
1 parent 9789bad commit 2d1d5ca
Show file tree
Hide file tree
Showing 57 changed files with 407 additions and 748 deletions.
15 changes: 9 additions & 6 deletions frontend/src/components/CoordinateRequestDialog.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import Swal from "sweetalert2";
import { useUserStore } from "@/stores";
import i18n from "@/i18n";
const { t } = i18n.global;

export function requestCoordinate() {
const apiUrl = import.meta.env.VITE_API_URL;
// Lets pop up a swal to ask for the seed name and then send it to the backend
Swal.fire({
title: "Request a seed thats not found in the database yet",
title: t("coordinate_request_dialog.text"),
input: "text",
inputLabel: "Coordinate:",
inputPlaceholder: "Enter the Coordinate here...",
inputLabel: t("coordinate_request_dialog.coordinate"),
inputPlaceholder: t("coordinate_request_dialog.placeholder"),
showCancelButton: true,
confirmButtonText: "Request",
confirmButtonText: t("coordinate_request_dialog.bt_request"),
cancelButtonText: t("coordinate_request_dialog.bt_cancel"),
showLoaderOnConfirm: true,
inputValidator: (coordinate) => validateCoordinate(coordinate),
preConfirm: (coordinates) => {
Expand Down Expand Up @@ -38,7 +41,7 @@ export function requestCoordinate() {
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
title: "Seed Requested",
title: t("coordinate_request_dialog.request_successful"),
text: result.value.message,
icon: "success",
});
Expand All @@ -54,7 +57,7 @@ export function validateCoordinate(coordinate) {
console.log(coordinate);
let coordinateValid = coordinateValidationRegex.test(coordinate);
if (!coordinateValid) {
resolve("Not a valid Coordinate!");
resolve(t("coordinate_request_dialog.invalid_syntax"));
} else {
resolve();
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import { Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/vue";
<!-- Optionally, add buttons to set or clear token -->
<div class="nav-link my-auto">
<button v-if="isAuthenticated" @click="requestCoordinate" class="btn btn-sm btn-primary">
{{ $t("coordinate_request_dialog.request_coordinate_title") }}
{{ $t("coordinate_request_dialog.title") }}
</button>
<a v-else :href="loginUrl">
<img src="https://community.cloudflare.steamstatic.com/public/images/signinthroughsteam/sits_01.png" />
Expand Down
21 changes: 8 additions & 13 deletions frontend/src/content/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
## Contribution Guide

We welcome contributions to help translate the website into different languages! Whether you're a developer or someone interested in contributing translations, here’s how you can help:

---

### For Developers:
1. Folder Structure:
- Navigate to the content folder, where all localization files are stored.
- Create a new folder named after the language code you want to translate (e.g., `zh` for Chinese, `de` for German, `ko` for Korean). You can refer to the BCP 47 standard for valid language and locale codes.
2. Follow the Existing Structure:
- Use the `en` folder (which contains the English translations) as a reference. Make sure your new folder follows the same structure and file names as the `en` folder to ensure consistency across translations.
3. Translation Files:
- Each page or component of the site will have its own javascript file associated within the content folder (e.g., home.js, navbar.js).
- Translate the content in each of these files into the appropriate language, ensuring the structure remains the same (keys must not be altered).
- Make sure you modify `index.js` file to include your translation.
4. Testing:
- After adding or updating a translation, make sure to test your changes by running the website locally to verify that the translations display correctly.
5. Submitting:
- Once you’ve made your changes, submit a pull request for review.

1. Copy the file "en.json" in the /locales/ folder and rename it to your target language code (e.g., `zh` for Chinese, `de` for German, `ko` for Korean) You can refer to the BCP 47 standard for valid language and locale codes.
2. Translate each of the entries.
3. Add the language code to the "locales" array in @/i18n.js and update the imports
4. After adding or updating a translation, make sure to test your changes by running the website locally to verify that the translations display correctly.
5. Once you’ve made your changes, submit a pull request for review.

---

### For Non-Developers:

If you're not a developer but would still like to contribute translations, you can leave the translated content as a comment on [this issue](https://github.com/barratt/mapsnotincluded.org/issues/30). One of the contributors will incorporate your translations into the project. You can try to match the structure of the contents in `/frontend/src/content/en` folder so that it is easier for developers to add in the translation.

---
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/src/content/en/components/navbar.js

This file was deleted.

25 changes: 0 additions & 25 deletions frontend/src/content/en/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/content/en/view/about.js

This file was deleted.

47 changes: 0 additions & 47 deletions frontend/src/content/en/view/contribute.js

This file was deleted.

15 changes: 0 additions & 15 deletions frontend/src/content/en/view/home.js

This file was deleted.

46 changes: 0 additions & 46 deletions frontend/src/content/en/view/map_explorer.js

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/content/en/view/map_explorer_steps.js

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/src/content/en/view/not_found.js

This file was deleted.

7 changes: 0 additions & 7 deletions frontend/src/content/en/view/seed_viewer.js

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/src/content/en/view/starmap_generator.js

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/src/content/en/view/world_trait_finder.js

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/content/ko/components/navbar.js

This file was deleted.

23 changes: 0 additions & 23 deletions frontend/src/content/ko/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/content/ko/view/about.js

This file was deleted.

47 changes: 0 additions & 47 deletions frontend/src/content/ko/view/contribute.js

This file was deleted.

13 changes: 0 additions & 13 deletions frontend/src/content/ko/view/home.js

This file was deleted.

Loading

0 comments on commit 2d1d5ca

Please sign in to comment.