Skip to content

Commit

Permalink
major: Added additional localisation and locale setting preservation
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-Klatzer committed Sep 16, 2024
1 parent 2b3a960 commit 6cfc6de
Show file tree
Hide file tree
Showing 26 changed files with 257 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"documentation",
"kipper"
],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"author": "Luna Klatzer",
"engines": {
"node": ">=16.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/changelog.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Page EJS Config -->
<% let title = "Changelog"; %>
<% let description = "Detailed Changelog documenting changes in Kipper."; %>
<% let title = locale["values"]["pages"]["changelog"]["title"]; %>
<% let description = locale["values"]["pages"]["changelog"]["description"]; %>

<!DOCTYPE html>
<html lang="en">
Expand Down
4 changes: 2 additions & 2 deletions src/docs/0.10.4/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Example `package.json`:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/cli": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down Expand Up @@ -222,7 +222,7 @@ Example package.json:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/core": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down
4 changes: 2 additions & 2 deletions src/docs/0.9.2/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Example `package.json`:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/cli": "latest"
}
Expand Down Expand Up @@ -131,7 +131,7 @@ Example package.json
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/core": "latest"
}
Expand Down
4 changes: 2 additions & 2 deletions src/docs/latest/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Example `package.json`:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/cli": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down Expand Up @@ -223,7 +223,7 @@ Example package.json:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/core": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down
4 changes: 2 additions & 2 deletions src/docs/next/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Example `package.json`:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/cli": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down Expand Up @@ -223,7 +223,7 @@ Example package.json:
"version": "0.1.0",
"description": "An example program using Kipper",
"keywords": ["kipper", "example"],
"license": "GPL-3.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@kipper/core": "latest" // <-- Add this line to your dependencies (choose latest, next or a specific version)
}
Expand Down
4 changes: 2 additions & 2 deletions src/download.ejs → src/downloads.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Page EJS Config -->
<% let title = "Downloads"; %>
<% let description = "Downloads for the Kipper Language."; %>
<% let title = locale["values"]["pages"]["downloads"]["title"]; %>
<% let description = locale["values"]["pages"]["downloads"]["description"]; %>

<!DOCTYPE html>
<html lang="en">
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/index.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- Page EJS Config -->
<% let title = "Welcome to Kipper!"; %>
<% let description = "The new customisable and easy to use type-safe language for the web and Node.js! "; %>
<% let title = locale["values"]["pages"]["homepage"]["title"]; %>
<% let description = locale["values"]["pages"]["homepage"]["description"]; %>

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
9 changes: 9 additions & 0 deletions src/js/global/locale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// declare "locale" on the global object
export {};

declare global {
interface Window {

Check warning on line 5 in src/js/global/locale.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used

Check warning on line 5 in src/js/global/locale.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used

Check warning on line 5 in src/js/global/locale.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used
locale: Record<string, any>;
localeKey: string;
}
}
8 changes: 8 additions & 0 deletions src/js/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ function toggleVisibility(dropdown: HTMLUListElement) {
localeSelectorButton.addEventListener("click", () => toggleVisibility(localeSelectorDropdown));
phoneSelectorButton.addEventListener("click", () => toggleVisibility(phoneSelectorDropdown));
console.log(localeSelectorDropdown, localeSelectorButton, phoneSelectorDropdown, phoneSelectorButton);

const localeSelectorItems = document.querySelectorAll("#header-nav-bar #locales-dropdown li.locale-selector-button-wrapper");
localeSelectorItems.forEach((item) => {
item.addEventListener("click", () => {
const locale = item.getAttribute("data-locale");
localStorage.setItem(window.localeKey, locale);
});
});
6 changes: 3 additions & 3 deletions src/js/playground/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function init(): void {
localStorage.setItem(localStorageIdentifier, givenTextArea.value);

spinning = false;
textSavingState.innerHTML = `<p class="gray-text">Saved!</p>`;
textSavingState.innerHTML = `<p class="gray-text">${window.locale["values"]["playground"]["save-state"]["saved"]}</p>`;
}, 1000);

if (!spinning) {
Expand All @@ -182,7 +182,7 @@ export function init(): void {
<div></div>
<div></div>
</div>
<p class="gray-text">Saving...</p>
<p class="gray-text">${window.locale["values"]["playground"]["save-state"]["saving"]}</p>
`;
spinning = true;
}
Expand All @@ -200,6 +200,6 @@ export function init(): void {

// If the input is not empty, signalize that code was restored
if (codeTextArea.value.trim() !== "") {
textSavingState.innerHTML = `<p class="gray-text">Loaded :)</p>`;
textSavingState.innerHTML = `<p class="gray-text">${window.locale["values"]["playground"]["save-state"]["loaded"]} :)</p>`;
}
}
2 changes: 1 addition & 1 deletion src/js/search-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const rawSearchIndex: Array<string> = [
"Playground;/playground.html;Playground;Online Playground for using Kipper in your browser.",
"Docs;/docs/index.html;Documentation;Kipper Documentation and API Reference.",
"Changelog;/changelog.html;Changelog;Detailed Changelog documenting changes in Kipper.",
"Downloads;/download.html;Downloads;Downloads.",
"Downloads;/downloads.html;Downloads;Downloads.",
"Comments;/docs/comments.html;Comments;Comments in the Kipper language.",
];

Expand Down
53 changes: 53 additions & 0 deletions src/locales/de-AT.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
{
"name": "de-AT",
"values": {
"pages": {
"homepage": {
"title": "Willkommen bei Kipper!",
"description": "Die neue anpassbare und einfach zu bedienende typsichere Sprache fürs Web und Node.js!"
},
"downloads": {
"title": "Downloads",
"description": "Lade die neueste Version von Kipper für dein Betriebssystem herunter."
},
"docs": {
"title": "Dokumentation",
"description": "Lerne, wie du Kipper mit unserer umfassenden Dokumentation verwenden kannst."
},
"playground": {
"title": "Playground",
"description": "Probiere Kipper in unserem Online-Playground aus."
},
"changelog": {
"title": "Änderungen",
"description": "Sieh dir die neuesten Änderungen an Kipper an."
}
},
"homepage": {
"welcome": "Willkommen bei Kipper!",
"description": "Die neue anpassbare und einfach zu bedienende typsichere Sprache fürs Web und Node.js!",
"play-button": "Playground ausprobieren",
"docs-button": "Doku anzeigen"
},
"nav-bar": {
"downloads": "Downloads",
"docs": "Doku",
"playground": "Playground",
"changelog": "Änderungen"
},
"playground": {
"buttons": {
"run": "Ausführen",
"copy": "Kopieren",
"clear": "Löschen",
"console": "Konsole",
"compiler": "Compiler"
},
"save-state": {
"saving": "Speichern...",
"saved": "Gespeichert!",
"loaded": "Geladen :)"
}
},
"footer": {
"supported-by": "Entwickelt bei und unterstützt von:",
"list": {
"releases": "Versionen",
"github": "GitHub",
"security": "Sicherheit",
"issues": "Issues",
"license": "Lizenz"
},
"license": "Kipper ist unter der GPL-3.0-or-later lizenziert."
}
}
}
53 changes: 53 additions & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
{
"name": "en-US",
"values": {
"pages": {
"homepage": {
"title": "Welcome to Kipper!",
"description": "The new customisable and easy to use type-safe language for the web and Node.js!"
},
"downloads": {
"title": "Downloads",
"description": "Download the latest version of Kipper for your platform."
},
"docs": {
"title": "Documentation",
"description": "Learn how to use Kipper with our comprehensive documentation."
},
"playground": {
"title": "Playground",
"description": "Try out Kipper in our online playground."
},
"changelog": {
"title": "Changelog",
"description": "View the latest changes to Kipper."
}
},
"homepage": {
"welcome": "Welcome to Kipper!",
"description": "The new customisable and easy to use type-safe language for the web and Node.js!",
"play-button": "Try our Playground",
"docs-button": "View the Docs"
},
"nav-bar": {
"downloads": "Downloads",
"docs": "Docs",
"playground": "Playground",
"changelog": "Changelog"
},
"playground": {
"buttons": {
"run": "Run",
"copy": "Copy",
"clear": "Clear",
"console": "Console",
"compiler": "Compiler"
},
"save-state": {
"saving": "Saving...",
"saved": "Saved!",
"loaded": "Loaded :)"
}
},
"footer": {
"supported-by": "Developed at and supported by:",
"list": {
"releases": "Releases",
"github": "GitHub",
"security": "Security",
"issues": "Issue Tracker",
"license": "License"
},
"license": "Kipper is licensed under the GPL-3.0-or-later license."
}
}
}
53 changes: 53 additions & 0 deletions src/locales/ja-JP.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
{
"name": "ja-JP",
"values": {
"pages": {
"homepage": {
"title": "Kipperへようこそ!",
"description": "新しいカスタマイズ可能で使いやすいWebとNode.jsのための型安全な言語!"
},
"downloads": {
"title": "ダウンロード",
"description": "お使いのプラットフォーム用のKipperの最新バージョンをダウンロードしてください。"
},
"docs": {
"title": "ドキュメント",
"description": "包括的なドキュメントでKipperの使い方を学びます。"
},
"playground": {
"title": "プレイグラウンド",
"description": "オンラインプレイグラウンドでKipperを試してみてください。"
},
"changelog": {
"title": "変更履歴",
"description": "Kipperの最新の変更を表示します。"
}
},
"homepage": {
"welcome": "Kipperへようこそ!",
"description": "新しいカスタマイズ可能で使いやすいWebとNode.jsのための型安全な言語!",
"play-button": "プレイグラウンドを試してみる",
"docs-button": "ドキュメントを見る"
},
"nav-bar": {
"downloads": "ダウンロード",
"docs": "ドキュメント",
"playground": "プレイグラウンド",
"changelog": "変更履歴"
},
"playground": {
"buttons": {
"run": "実行",
"copy": "コピー",
"clear": "クリア",
"console": "コンソール",
"compiler": "コンパイラ"
},
"save-state": {
"saving": "保存中...",
"saved": "保存されました!",
"loaded": "ロードされました :)"
}
},
"footer": {
"supported-by": "開発元・サポート元:",
"list": {
"releases": "リリース",
"github": "GitHub",
"security": "セキュリティ",
"issues": "問題トラッカー",
"license": "ライセンス"
},
"license": "KipperはGPL-3.0-or-laterライセンスで提供されます。"
}
}
}
Loading

0 comments on commit 6cfc6de

Please sign in to comment.