feat(editor): add i18n support for block meta display (#10831)

This commit is contained in:
Saul-Mirone
2025-03-13 11:28:56 +00:00
parent 0c9591f08e
commit 05f3069efd
7 changed files with 59 additions and 30 deletions
@@ -8,6 +8,7 @@
"include": ["./src"],
"references": [
{ "path": "../../components" },
{ "path": "../../gfx/turbo-renderer" },
{ "path": "../../model" },
{ "path": "../../rich-text" },
{ "path": "../../shared" },
@@ -8,6 +8,7 @@
"include": ["./src"],
"references": [
{ "path": "../../../framework/block-std" },
{ "path": "../../../framework/global" }
{ "path": "../../../framework/global" },
{ "path": "../../../framework/store" }
]
}
@@ -6,7 +6,7 @@ import {
import { WorkspaceServerService } from '@affine/core/modules/cloud';
import { EditorService } from '@affine/core/modules/editor';
import { copyLinkToBlockStdScopeClipboard } from '@affine/core/utils/clipboard';
import { I18n } from '@affine/i18n';
import { I18n, i18nTime } from '@affine/i18n';
import { track } from '@affine/track';
import {
BlockFlavourIdentifier,
@@ -346,28 +346,36 @@ function createToolbarMoreMenuConfigV2(baseUrl?: string) {
const userProvider = cx.std.get(UserProvider);
userProvider.revalidateUserInfo(createdByUserId);
const userSignal = userProvider.userInfo$(createdByUserId);
userSignal.subscribe(console.log);
const user = computed(() => {
const name = computed(() => {
const value = userSignal.value;
if (!value) return 'Unknown User';
if (!value) return I18n['Unknown User']();
const removed = isRemovedUserInfo(value);
if (removed) return 'Deleted User';
if (removed) {
return I18n['Deleted User']();
}
return value.name;
});
const createdAtString = date.toLocaleString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true,
const user = computed(() => {
return I18n.t('com.affine.page.toolbar.created_by', {
name: name.value,
});
});
const createdAtString = i18nTime(date.toISOString(), {
relative: {
max: [1, 'day'],
accuracy: 'minute',
weekday: true,
},
absolute: {
accuracy: 'minute',
},
});
const wrapperStyle = {
padding: '4px 8px',
fontSize: '12px',
};
return html`<div style=${styleMap(wrapperStyle)}>
<div>Created by ${watch(user)}</div>
<div>${watch(user)}</div>
<div>${createdAtString}</div>
</div>`;
},
@@ -1,26 +1,26 @@
{
"ar": 99,
"ar": 98,
"ca": 4,
"da": 5,
"de": 99,
"el-GR": 99,
"de": 98,
"el-GR": 98,
"en": 100,
"es-AR": 99,
"es-AR": 98,
"es-CL": 100,
"es": 99,
"fa": 99,
"fr": 99,
"es": 98,
"fa": 98,
"fr": 98,
"hi": 2,
"it-IT": 99,
"it-IT": 98,
"it": 1,
"ja": 99,
"ja": 98,
"ko": 62,
"pl": 99,
"pt-BR": 99,
"ru": 99,
"sv-SE": 99,
"uk": 99,
"pl": 98,
"pt-BR": 98,
"ru": 98,
"sv-SE": 98,
"uk": 98,
"ur": 2,
"zh-Hans": 99,
"zh-Hant": 99
"zh-Hans": 98,
"zh-Hant": 98
}
+14
View File
@@ -577,6 +577,14 @@ export function useAFFiNEI18N(): {
* `Zoom out`
*/
["Zoom out"](): string;
/**
* `Unknown User`
*/
["Unknown User"](): string;
/**
* `Deleted User`
*/
["Deleted User"](): string;
/**
* `all`
*/
@@ -3105,6 +3113,12 @@ export function useAFFiNEI18N(): {
* `Select all`
*/
["com.affine.page.group-header.select-all"](): string;
/**
* `Created by {{name}}`
*/
["com.affine.page.toolbar.created_by"](options: {
readonly name: string;
}): string;
/**
* `Doc mode`
*/
@@ -133,6 +133,8 @@
"Workspace saved locally": "{{name}} is saved locally",
"Zoom in": "Zoom in",
"Zoom out": "Zoom out",
"Unknown User": "Unknown User",
"Deleted User": "Deleted User",
"all": "all",
"com.affine.aboutAFFiNE.autoCheckUpdate.description": "Automatically check for new updates periodically.",
"com.affine.aboutAFFiNE.autoCheckUpdate.title": "Check for updates automatically",
@@ -775,6 +777,7 @@
"com.affine.page.toolbar.selected_one": "<0>{{count}}</0> doc selected",
"com.affine.page.toolbar.selected_other": "<0>{{count}}</0> doc(s) selected",
"com.affine.page.toolbar.selected_others": "<0>{{count}}</0> doc(s) selected",
"com.affine.page.toolbar.created_by": "Created by {{name}}",
"com.affine.pageMode": "Doc mode",
"com.affine.pageMode.all": "all",
"com.affine.pageMode.edgeless": "Edgeless",
+2
View File
@@ -269,6 +269,7 @@ export const PackageList = [
name: '@blocksuite/affine-block-paragraph',
workspaceDependencies: [
'blocksuite/affine/components',
'blocksuite/affine/gfx/turbo-renderer',
'blocksuite/affine/model',
'blocksuite/affine/rich-text',
'blocksuite/affine/shared',
@@ -454,6 +455,7 @@ export const PackageList = [
workspaceDependencies: [
'blocksuite/framework/block-std',
'blocksuite/framework/global',
'blocksuite/framework/store',
],
},
{