Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label component inspector localization #16234

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions cocos/2d/components/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/

import { ccclass, help, executionOrder, menu, tooltip, displayOrder, visible, multiline, type, serializable, editable } from 'cc.decorator';
import { ccclass, help, executionOrder, menu, displayOrder, visible, multiline, type, serializable, editable } from 'cc.decorator';
import { BYTEDANCE, EDITOR, JSB } from 'internal:constants';
import { minigame } from 'pal/minigame';
import { BitmapFont, Font, SpriteFrame } from '../assets';
Expand Down Expand Up @@ -212,7 +212,6 @@ export class Label extends UIRenderer {
* 标签显示的文本内容。
*/
@displayOrder(4)
@tooltip('i18n:label.string')
@multiline
get string (): string {
return this._string;
Expand Down Expand Up @@ -241,7 +240,6 @@ export class Label extends UIRenderer {
*/
@type(HorizontalTextAlignment)
@displayOrder(5)
@tooltip('i18n:label.horizontal_align')
get horizontalAlign (): HorizontalTextAlignment {
return this._horizontalAlign;
}
Expand All @@ -263,7 +261,6 @@ export class Label extends UIRenderer {
*/
@type(VerticalTextAlignment)
@displayOrder(6)
@tooltip('i18n:label.vertical_align')
get verticalAlign (): VerticalTextAlignment {
return this._verticalAlign;
}
Expand Down Expand Up @@ -298,7 +295,6 @@ export class Label extends UIRenderer {
* 文本字体大小。
*/
@displayOrder(7)
@tooltip('i18n:label.font_size')
get fontSize (): number {
return this._fontSize;
}
Expand All @@ -319,7 +315,6 @@ export class Label extends UIRenderer {
* 文本行高。
*/
@displayOrder(8)
@tooltip('i18n:label.line_height')
get lineHeight (): number {
return this._lineHeight;
}
Expand All @@ -343,7 +338,6 @@ export class Label extends UIRenderer {
return !this._isSystemFontUsed && this._font instanceof BitmapFont;
})
@displayOrder(9)
@tooltip('i18n:label.spacing_x')
get spacingX (): number {
return this._spacingX;
}
Expand All @@ -365,7 +359,6 @@ export class Label extends UIRenderer {
*/
@type(Overflow)
@displayOrder(10)
@tooltip('i18n:label.overflow')
get overflow (): Overflow {
return this._overflow;
}
Expand All @@ -386,7 +379,6 @@ export class Label extends UIRenderer {
* 是否自动换行。
*/
@displayOrder(11)
@tooltip('i18n:label.wrap')
get enableWrapText (): boolean {
return this._enableWrapText;
}
Expand All @@ -407,7 +399,6 @@ export class Label extends UIRenderer {
* 是否使用系统字体。
*/
@displayOrder(12)
@tooltip('i18n:label.system_font')
get useSystemFont (): boolean {
return this._isSystemFontUsed;
}
Expand Down Expand Up @@ -443,7 +434,6 @@ export class Label extends UIRenderer {
*/
@displayOrder(13)
@visible(function (this: Label) { return this._isSystemFontUsed; })
@tooltip('i18n:label.font_family')
get fontFamily (): string {
return this._fontFamily;
}
Expand All @@ -466,7 +456,6 @@ export class Label extends UIRenderer {
@type(Font)
@displayOrder(13)
@visible(function (this: Label) { return !this._isSystemFontUsed; })
@tooltip('i18n:label.font')
get font (): Font | null {
// return this._N$file;
return this._font;
Expand Down Expand Up @@ -503,7 +492,6 @@ export class Label extends UIRenderer {
*/
@type(CacheMode)
@displayOrder(14)
@tooltip('i18n:label.cache_mode')
get cacheMode (): CacheMode {
return this._cacheMode;
}
Expand Down Expand Up @@ -531,7 +519,6 @@ export class Label extends UIRenderer {
* 字体是否加粗。
*/
@displayOrder(15)
@tooltip('i18n:label.font_bold')
get isBold (): boolean {
return this._isBold;
}
Expand All @@ -552,7 +539,6 @@ export class Label extends UIRenderer {
* 字体是否倾斜。
*/
@displayOrder(16)
@tooltip('i18n:label.font_italic')
get isItalic (): boolean {
return this._isItalic;
}
Expand All @@ -573,7 +559,6 @@ export class Label extends UIRenderer {
* 字体是否加下划线。
*/
@displayOrder(17)
@tooltip('i18n:label.font_underline')
get isUnderline (): boolean {
return this._isUnderline;
}
Expand All @@ -593,7 +578,6 @@ export class Label extends UIRenderer {
@visible(function (this: Label) { return this._isUnderline; })
@editable
@displayOrder(18)
@tooltip('i18n:label.underline_height')
get underlineHeight (): number {
return this._underlineHeight;
}
Expand All @@ -613,7 +597,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont); })
@displayOrder(19)
@tooltip('i18n:label.outline_enable')
get enableOutline (): boolean {
return this._enableOutline;
}
Expand All @@ -633,7 +616,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })
@displayOrder(20)
@tooltip('i18n:label.outline_color')
get outlineColor (): Color {
return this._outlineColor;
}
Expand All @@ -653,7 +635,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })
@displayOrder(21)
@tooltip('i18n:label.outline_width')
get outlineWidth (): number {
return this._outlineWidth;
}
Expand All @@ -670,7 +651,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })
@displayOrder(22)
@tooltip('i18n:label.shadow_enable')
get enableShadow (): boolean {
return this._enableShadow;
}
Expand All @@ -690,7 +670,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })
@displayOrder(23)
@tooltip('i18n:label.shadow_color')
get shadowColor (): Color {
return this._shadowColor;
}
Expand All @@ -710,7 +689,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })
@displayOrder(24)
@tooltip('i18n:label.shadow_offset')
get shadowOffset (): Vec2 {
return this._shadowOffset;
}
Expand All @@ -730,7 +708,6 @@ export class Label extends UIRenderer {
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })
@displayOrder(25)
@tooltip('i18n:label.shadow_blur')
get shadowBlur (): number {
return this._shadowBlur;
}
Expand Down
2 changes: 0 additions & 2 deletions cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class UIRenderer extends Renderer {
*/
@type(Material)
@displayOrder(0)
@tooltip('i18n:UIRenderer.customMaterial')
@displayName('CustomMaterial')
@disallowAnimation
get customMaterial (): Material | null {
Expand All @@ -185,7 +184,6 @@ export class UIRenderer extends Renderer {
* @zh 渲染颜色,一般情况下会和贴图颜色相乘。
*/
@displayOrder(1)
@tooltip('i18n:UIRenderer.color')
get color (): Readonly<Color> {
return this._color;
}
Expand Down
28 changes: 1 addition & 27 deletions editor/i18n/en/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,37 +384,12 @@ module.exports = link(mixin({
space: 'Space where acceleration calculated',
},
label: {
string: 'Text of the Label',
horizontal_align: 'Horizontal alignment',
horizontal_align_left: 'Align Left',
horizontal_align_center: 'Align Horizontal Center',
horizontal_align_right: 'Align Right',
vertical_align: 'Vertical alignment',
vertical_align_top: 'Align Top',
vertical_align_center: 'Align Vertical Center',
vertical_align_bottom: 'Align Bottom',
font_size: 'Font size, in points',
font_family: 'Font family name',
line_height: 'Line height, in points',
overflow:
'Text layout modes: <br> 1. CLAMP: Text nodes outside the bounding box will be truncated. <br> 2. SHRINK: Automatically shrink text box according to the constraint node. <br> 3. RESIZE: Automatically updates the Node based on heightof the text.',
wrap: 'Wrap text?',
font: 'What font to use',
system_font: 'Whether to use the system default font',
cache_mode:
'Text cache modes:<br> 1. NONE: No cache,draw once. <br> 2. BITMAP: Text is added as a static image to the dynamic atlas for batch merging, but its content cannot be dynamically modified frequently. <br> 3. CHAR: Split the text into characters and cache the character texture into a character atlas for reuse, which is suitable for text content with repeated character content and frequently updated.',
font_bold: 'Font bold',
font_italic: 'Font italic',
font_underline: 'Font underlined',
spacing_x: 'The spacing between text characters, only available in BMFont',
underline_height: 'The height of underline',
outline_enable: 'Whether outline is enabled',
outline_width: 'The width of outline',
outline_color: 'The color of outline',
shadow_enable: 'Whether shadow is enabled',
shadow_color: 'The color of shadow',
shadow_offset: 'Offset between font and shadow',
shadow_blur: 'A non-negative float specifying the level of shadow blur',
},
labelOutline: {
color: 'Outline color',
Expand Down Expand Up @@ -500,8 +475,6 @@ module.exports = link(mixin({
UIRenderer: {
srcBlendFactor: 'Source blend factor',
dstBlendFactor: 'Destination blend factor',
customMaterial: 'User specified material',
color: 'Render color',
},
rotationOvertimeModule: {
separateAxes: 'Set rotation of X, Y and Z respectively (not supported now)',
Expand Down Expand Up @@ -1344,6 +1317,7 @@ module.exports = link(mixin({
},

require('./modules/rendering'),
require('./modules/ui.js'),
require('./animation'),

));
124 changes: 124 additions & 0 deletions editor/i18n/en/modules/ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* eslint-disable quote-props */

module.exports = {
classes: {
'cc': {
'UIRenderer': {
properties: {
customMaterial: {
displayName: 'Custom Material',
tooltip: 'Use custom material.',
},
color: {
displayName: 'Color',
tooltip: 'Rendering color.',
},
},
},
'Label': {
properties: {
__extends__: 'classes.cc.UIRenderer.properties',
'string': {
displayName: 'string',
tooltip: 'The label text.',
},
'horizontalAlign': {
displayName: 'Horizontal Alignment',
tooltip: 'Horizontal alignment mode.',
},
'verticalAlign': {
displayName: 'Vertical Alignment',
tooltip: 'Vertical alignment mode.',
},
'fontSize': {
displayName: 'Font Size',
tooltip: 'Font size, in points.',
},
'lineHeight': {
displayName: 'Line Height',
tooltip: 'Line height, in points.',
},
'spacingX': {
displayName: 'Horizontal Spacing',
tooltip: 'The spacing between text characters, only available if bitmap font was used.',
},
'overflow': {
displayName: 'Overflow Processing',
tooltip: 'Text layout modes: <br> ' +
'1. CLAMP: Text nodes outside the bounding box will be truncated. <br> ' +
'2. SHRINK: Automatically shrink text box according to the constraint node. <br> ' +
'3. RESIZE: Automatically updates the Node based on height of the text.',
},
'enableWrapText': {
displayName: 'Auto Newline',
tooltip: 'Automatic newline.',
},
'useSystemFont': {
displayName: 'System Fonts',
tooltip: 'Whether to use system default fonts. The referenced font asset would be dereferenced once this option was checked.',
},
'fontFamily': {
displayName: 'Font Family',
tooltip: 'Font names.',
},
'font': {
displayName: 'Font',
tooltip: 'The font asset to use.',
},
'cacheMode': {
displayName: 'Cache Mode',
tooltip: 'Text cache modes:<br> ' +
'1. NONE: No cache,draw once. <br> ' +
'2. BITMAP: Text is added as a static image to the dynamic atlas for batch merging, but its content cannot be dynamically modified frequently. <br> ' +
'3. CHAR: Split the text into characters and cache the character texture into a character atlas for reuse, ' +
'which is suitable for text content with repeated character content and frequently updated.',
},
'isBold': {
displayName: 'Bold',
tooltip: 'Make words bold.',
},
'isItalic': {
displayName: 'Italic',
tooltip: 'Make words italic.',
},
'isUnderline': {
displayName: 'Underline',
tooltip: 'Underscore the words.',
},
'underlineHeight': {
displayName: 'Underline Height',
tooltip: 'The underline\'s height.',
},
'enableOutline': {
displayName: 'Enable Outline',
tooltip: 'Whether outline is enabled.',
},
'outlineColor': {
displayName: 'Outline Color',
tooltip: 'The color of outline.',
},
'outlineWidth': {
displayName: 'Outline Width',
tooltip: 'The width of outline',
},
'enableShadow': {
displayName: 'Enable Shadow',
tooltip: 'Whether shadow is enabled.',
},
'shadowColor': {
displayName: 'Enable Outline',
tooltip: 'The color of shadow.',
},
'shadowOffset': {
displayName: 'Shadow Offset',
tooltip: 'Offset between font and shadow.',
},
'shadowBlur': {
displayName: 'Shadow Blur',
tooltip: 'A non-negative float specifying the level of shadow blur.',
},
},
},
},
},
};
Loading