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