Skip to content

Commit

Permalink
fix: Re-add the mistakenly deleted issues template and optimize i18n …
Browse files Browse the repository at this point in the history
…implementation
  • Loading branch information
TNXG committed Jan 6, 2025
1 parent b27ca3d commit 29ff240
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 32 deletions.
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/🚀-enhancement-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: "\U0001F680 Enhancement Request"
about: Suggest an idea for this project
title: ""
labels: enhancement
assignees: ""
---

**Title:** 🚀 Enhancement Request: [Brief Description of the Enhancement]

**Date:** [Date]

**Affected Version:** [Version Number] (if applicable)

**Description:**
A detailed description of the proposed enhancement. Explain what new functionality or improvement is being suggested and why it would be beneficial.

**Motivation:**
Explain why this enhancement is needed. Include any problems it will solve or improvements it will bring to the user experience.

**Proposed Changes:**

1. **Feature Addition:** [Describe the new feature or functionality in detail]
2. **UI/UX Improvements:** [If applicable, describe any changes to the user interface or user experience]
3. **Performance Enhancements:** [If applicable, describe how the enhancement will improve performance]

**Benefits:**
List the advantages and benefits of implementing this enhancement. Explain how it will improve the product or user experience.

**Examples:**
Provide any examples or use cases that illustrate the enhancement. Include mockups, wireframes, or screenshots if available.

**Additional Information:**

- [Any additional context or information that would be helpful]
- [Include any related issues or requests if applicable]

**Priority:** [Low/Medium/High]

**Estimated Effort:** [Estimate the effort required to implement this enhancement, if known]

**Contact Information:**

- Name: [Your Name]
- Email: [Your Email]
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/🛠️-bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: "\U0001F6E0️ Bug report"
about: Create a report to help us improve
title: ""
labels: bug
assignees: ""
---

**Title:** 🛠️ Bug Report: [Brief Description of the Issue]

**Date:** [Date]

**Affected Version:** [Version Number]

**Description:**
A detailed description of the bug or issue. Include any error messages, unexpected behavior, or deviations from the expected functionality.

**Steps to Reproduce:**

1. [First step to reproduce the issue]
2. [Second step to reproduce the issue]
3. [Additional steps if necessary]

**Expected Result:**
Describe what should have happened if the bug did not exist.

**Actual Result:**
Describe what actually happened, including any error messages or incorrect behavior.

**Screenshots or Attachments:**
[Attach any relevant screenshots, logs, or files that help illustrate the issue]

**Additional Information:**

- [Any additional information that might help in diagnosing the problem]
- [If the issue is related to specific conditions or user actions, mention those here]

**Severity:** [Low/Medium/High/Critical]

**Priority:** [Low/Medium/High]

**Workaround:** [If there is a temporary fix or workaround, describe it here]

**Proposed Fix or Solution:**
[If you have a suggestion for fixing the issue or know the cause, provide details here]

**Contact Information:**

- Name: [Your Name]
- Email: [Your Email]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store
.vercel
4 changes: 3 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { transformers } from "./src/config/transformers.js";

import { CODE_THEME } from "./src/consts.ts";

import { initI18n } from "./src/locales";
import { rehypeFadeInUp } from "./src/plugins/rehype-fade-in-up.mjs";
import { remarkAddAnchor } from "./src/plugins/remark-add-anchor.mjs";
import { remarkHeadingExtractor } from "./src/plugins/remark-heading-extractor.mjs";

import { remarkReadingTime } from "./src/plugins/remark-reading-time.mjs";

const { USER_SITE } = await import("./src/consts.ts");
Expand Down Expand Up @@ -49,7 +51,7 @@ export default defineConfig({
}), terser({
compress: true,
mangle: true,
}), sitemap(), tailwind(), pagefind(), playformCompress()],
}), sitemap(), tailwind(), pagefind(), playformCompress(), initI18n()],
markdown: {
shikiConfig: {
themes: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/BaseCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CardVertical from "../layouts/CardVertical.astro";
import { Icon } from "astro-icon/components";
import { DATE_FORMAT } from "../consts";
import type { CardInfo } from "../types";
import { t } from "@/locales";
import { t } from "i18next";
const {
title = "undefined",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getCollection } from "astro:content";
import CardAside from "../layouts/CardAside.astro";
import TagButton from "../widget/TagButton.astro";
import { t } from "@/locales";
import { t } from "i18next";
interface CategoryCount {
category: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/EnvelopeCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon } from "astro-icon/components";
import CardHorizontal from "../layouts/CardHorizontal.astro";
import type { EnvelopeInfo } from "../types";
import { DATE_FORMAT } from "../consts";
import { t } from "@/locales";
import { t } from "i18next";
const { title, desc, image, pubDate, badge, categories = [], tags = [], word, time, url } = Astro.props as EnvelopeInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/components/License.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { USER_NAME } from "../consts";
import { Icon } from "astro-icon/components";
import { t } from "@/locales";
import { t } from "i18next";
interface Props {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getCollection } from "astro:content";
import CardAside from "../layouts/CardAside.astro";
import TagButton from "../widget/TagButton.astro";
import { t } from "@/locales";
import { t } from "i18next";
interface TagCount {
tag: string;
Expand Down
26 changes: 3 additions & 23 deletions src/locales.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Callback, TFunction } from "i18next";
import { USER_SITE } from "@/consts";
import i18next from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import HttpApi from "i18next-http-backend";
import { USER_SITE } from "./consts";

async function initI18n() {
export function initI18n() {
if (i18next.isInitialized) {
return;
}
await i18next
i18next
.use(HttpApi)
.use(LanguageDetector)
.init({
Expand All @@ -23,22 +22,3 @@ async function initI18n() {
},
});
}

initI18n();

export async function changeLanguageTo(lng: string, callback?: Callback): Promise<TFunction> {
return i18next.changeLanguage(lng, callback);
}

export function t(key: string, options?: any): string {
const result = i18next.t(key, options);

if (typeof result !== "string") {
console.warn(`Warning: i18next translation for key '${key}' did not return a string.`);
return String(result);
}

return result;
}

export { i18next };
2 changes: 1 addition & 1 deletion src/pages/blog/categories/[category]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BaseLayout from "../../../../layouts/BaseLayout.astro";
import BaseCard from "../../../../components/BaseCard.astro";
import Pagination from "../../../../widget/Pagination.astro";
import { getCollection } from "astro:content";
import { t } from "@/locales";
import { t } from "i18next";
export async function getStaticPaths({ paginate }: { paginate: any }) {
const all_posts = await getCollection("blog");
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/tags/[tag]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BaseLayout from "../../../../layouts/BaseLayout.astro";
import BaseCard from "../../../../components/BaseCard.astro";
import Pagination from "../../../../widget/Pagination.astro";
import { getCollection } from "astro:content";
import { t } from "@/locales";
import { t } from "i18next";
export async function getStaticPaths({ paginate }: { paginate: any }) {
const all_posts = await getCollection("blog");
Expand Down
2 changes: 1 addition & 1 deletion src/widget/Pagination.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Page } from "../types";
import PaginationArrow from "./shared/PaginationArrow.astro";
import PaginationNumber from "./shared/PaginationNumber.astro";
import PaginationDropdown from "./shared/PaginationDropdown.astro";
import { t } from "@/locales";
import { t } from "i18next";
interface Props {
page: Page;
Expand Down

0 comments on commit 29ff240

Please sign in to comment.