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 @@
* 标签显示的文本内容。
*/
@displayOrder(4)
@tooltip('i18n:label.string')
@multiline
get string (): string {
return this._string;
Expand Down Expand Up @@ -241,7 +240,6 @@
*/
@type(HorizontalTextAlignment)
@displayOrder(5)
@tooltip('i18n:label.horizontal_align')
get horizontalAlign (): HorizontalTextAlignment {
return this._horizontalAlign;
}
Expand All @@ -263,7 +261,6 @@
*/
@type(VerticalTextAlignment)
@displayOrder(6)
@tooltip('i18n:label.vertical_align')
get verticalAlign (): VerticalTextAlignment {
return this._verticalAlign;
}
Expand Down Expand Up @@ -298,7 +295,6 @@
* 文本字体大小。
*/
@displayOrder(7)
@tooltip('i18n:label.font_size')
get fontSize (): number {
return this._fontSize;
}
Expand All @@ -319,7 +315,6 @@
* 文本行高。
*/
@displayOrder(8)
@tooltip('i18n:label.line_height')
get lineHeight (): number {
return this._lineHeight;
}
Expand All @@ -339,11 +334,10 @@
* @zh
* 文本字符之间的间距。仅在使用 BMFont 位图字体时生效。
*/
@visible(function (this: Label) {

Check warning on line 337 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
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 @@
*/
@type(Overflow)
@displayOrder(10)
@tooltip('i18n:label.overflow')
get overflow (): Overflow {
return this._overflow;
}
Expand All @@ -386,7 +379,6 @@
* 是否自动换行。
*/
@displayOrder(11)
@tooltip('i18n:label.wrap')
get enableWrapText (): boolean {
return this._enableWrapText;
}
Expand All @@ -407,7 +399,6 @@
* 是否使用系统字体。
*/
@displayOrder(12)
@tooltip('i18n:label.system_font')
get useSystemFont (): boolean {
return this._isSystemFontUsed;
}
Expand Down Expand Up @@ -442,8 +433,7 @@
* 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。
*/
@displayOrder(13)
@visible(function (this: Label) { return this._isSystemFontUsed; })

Check warning on line 436 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@tooltip('i18n:label.font_family')
get fontFamily (): string {
return this._fontFamily;
}
Expand All @@ -465,8 +455,7 @@
*/
@type(Font)
@displayOrder(13)
@visible(function (this: Label) { return !this._isSystemFontUsed; })

Check warning on line 458 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@tooltip('i18n:label.font')
get font (): Font | null {
// return this._N$file;
return this._font;
Expand Down Expand Up @@ -503,7 +492,6 @@
*/
@type(CacheMode)
@displayOrder(14)
@tooltip('i18n:label.cache_mode')
get cacheMode (): CacheMode {
return this._cacheMode;
}
Expand Down Expand Up @@ -531,7 +519,6 @@
* 字体是否加粗。
*/
@displayOrder(15)
@tooltip('i18n:label.font_bold')
get isBold (): boolean {
return this._isBold;
}
Expand All @@ -552,7 +539,6 @@
* 字体是否倾斜。
*/
@displayOrder(16)
@tooltip('i18n:label.font_italic')
get isItalic (): boolean {
return this._isItalic;
}
Expand All @@ -573,7 +559,6 @@
* 字体是否加下划线。
*/
@displayOrder(17)
@tooltip('i18n:label.font_underline')
get isUnderline (): boolean {
return this._isUnderline;
}
Expand All @@ -590,10 +575,9 @@
* @en The height of underline.
* @zh 下划线高度。
*/
@visible(function (this: Label) { return this._isUnderline; })

Check warning on line 578 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@editable
@displayOrder(18)
@tooltip('i18n:label.underline_height')
get underlineHeight (): number {
return this._underlineHeight;
}
Expand All @@ -611,9 +595,8 @@
** 描边效果组件,用于字体描边,只能用于系统字体或 ttf 字体。
**/
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont); })

Check warning on line 598 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(19)
@tooltip('i18n:label.outline_enable')
get enableOutline (): boolean {
return this._enableOutline;
}
Expand All @@ -631,9 +614,8 @@
* 改变描边的颜色。
*/
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })

Check warning on line 617 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(20)
@tooltip('i18n:label.outline_color')
get outlineColor (): Color {
return this._outlineColor;
}
Expand All @@ -651,9 +633,8 @@
* 改变描边的宽度。
*/
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })

Check warning on line 636 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(21)
@tooltip('i18n:label.outline_width')
get outlineWidth (): number {
return this._outlineWidth;
}
Expand All @@ -668,9 +649,8 @@
* @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。在缓存模式为 char 时不可用。
*/
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 652 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(22)
@tooltip('i18n:label.shadow_enable')
get enableShadow (): boolean {
return this._enableShadow;
}
Expand All @@ -688,9 +668,8 @@
* 阴影的颜色。
*/
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 671 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(23)
@tooltip('i18n:label.shadow_color')
get shadowColor (): Color {
return this._shadowColor;
}
Expand All @@ -708,9 +687,8 @@
* 字体与阴影的偏移。
*/
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 690 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(24)
@tooltip('i18n:label.shadow_offset')
get shadowOffset (): Vec2 {
return this._shadowOffset;
}
Expand All @@ -730,7 +708,6 @@
@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
Loading