fix(i18n): hardcoded strings in repository activity graphs (#11735)

This PR removes hard-coded string from the activities page.
Resolves https://codeberg.org/forgejo/forgejo/issues/11680

Co-authored-by: Minh Nguyen <44615298+minh160302@users.noreply.github.com>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Beowulf <beowulf@beocode.eu>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11735
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: minh160302 <minh160302@noreply.codeberg.org>
Co-committed-by: minh160302 <minh160302@noreply.codeberg.org>
This commit is contained in:
minh160302 2026-03-19 15:41:33 +01:00 committed by 0ko
parent 04f6645c38
commit 6b2322f110
8 changed files with 26 additions and 2 deletions

View file

@ -561,5 +561,7 @@
"editor.toggle_regex": "Toggle using regular expressions",
"editor.toggle_whole_word": "Toggle matching whole words",
"form.RunnerName": "Name",
"graphs.recent_commits.title": "Number of commits in the past year",
"graphs.code_frequency.title": "Code frequency over the history of {0}",
"meta.last_line": "Thank you for translating Forgejo! This line isn't seen by the users but it serves other purposes in the translation management. You can place a fun fact in the translation instead of translating it."
}

View file

@ -2,6 +2,7 @@
<div id="repo-code-frequency-chart"
data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.code_frequency.what")}}"
data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.code_frequency.what")}}"
data-locale-code-frequency-title="{{ctx.Locale.Tr "graphs.code_frequency.title"}}"
data-locale-loading-info="{{ctx.Locale.Tr "graphs.component_loading_info"}}"
data-locale-component-failed-to-load="{{ctx.Locale.Tr "graphs.component_failed_to_load"}}"
>

View file

@ -2,6 +2,7 @@
<div id="repo-recent-commits-chart"
data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.recent_commits.what")}}"
data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.recent_commits.what")}}"
data-locale-recent-commits-title="{{ctx.Locale.Tr "graphs.recent_commits.title"}}"
data-locale-loading-info="{{ctx.Locale.Tr "graphs.component_loading_info"}}"
data-locale-component-failed-to-load="{{ctx.Locale.Tr "graphs.component_failed_to_load"}}"
>

View file

@ -15,3 +15,21 @@ test('Contributor graph', async ({page}) => {
await page.getByRole('link', {name: '2 Commits'}).click();
await expect(page.getByRole('cell', {name: 'Bob'})).toHaveCount(2);
});
test('Code frequency', async ({page}) => {
await page.goto('/user2/commits_search_test/activity/code-frequency');
/* Verify that Vue has access to i18n string */
const header = page.locator('#repo-code-frequency-chart .header');
await header.waitFor();
await expect(header).toContainText('Code frequency over the history of user2/commits_search_test');
});
test('Recent commits', async ({page}) => {
await page.goto('/user2/commits_search_test/activity/recent-commits');
/* Verify that Vue has access to i18n string */
const header = page.locator('#repo-recent-commits-chart .header');
await header.waitFor();
await expect(header).toContainText('Number of commits in the past year');
});

View file

@ -145,7 +145,7 @@ export default {
<template>
<div>
<div class="ui header tw-flex tw-items-center tw-justify-between">
{{ isLoading ? locale.loadingTitle : errorText ? locale.loadingTitleFailed: `Code frequency over the history of ${repoLink.slice(1)}` }}
{{ isLoading ? locale.loadingTitle : errorText ? locale.loadingTitleFailed : locale.codeFrequencyTitle.replace('{0}', repoLink.slice(1)) }}
</div>
<div class="tw-flex ui segment main-graph">
<div v-if="isLoading || errorText !== ''" class="gt-tc tw-m-auto">

View file

@ -122,7 +122,7 @@ export default {
<template>
<div>
<div class="ui header tw-flex tw-items-center tw-justify-between">
{{ isLoading ? locale.loadingTitle : errorText ? locale.loadingTitleFailed: "Number of commits in the past year" }}
{{ isLoading ? locale.loadingTitle : errorText ? locale.loadingTitleFailed : locale.recentCommitsTitle }}
</div>
<div class="tw-flex ui segment main-graph">
<div v-if="isLoading || errorText !== ''" class="gt-tc tw-m-auto">

View file

@ -11,6 +11,7 @@ export async function initRepoCodeFrequency() {
loadingTitle: el.getAttribute('data-locale-loading-title'),
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'),
loadingInfo: el.getAttribute('data-locale-loading-info'),
codeFrequencyTitle: el.getAttribute('data-locale-code-frequency-title'),
},
});
View.mount(el);

View file

@ -10,6 +10,7 @@ export async function initRepoRecentCommits() {
locale: {
loadingTitle: el.getAttribute('data-locale-loading-title'),
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'),
recentCommitsTitle: el.getAttribute('data-locale-recent-commits-title'),
loadingInfo: el.getAttribute('data-locale-loading-info'),
},
});