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

Editor: Fixed units ignore plural rules issue #28245

Merged
merged 1 commit into from
May 2, 2024
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
12 changes: 12 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ function Strings( config ) {
'viewport/controls/grid': 'Grid',
'viewport/controls/helpers': 'Helpers',

'viewport/info/oneObject': 'Object',
'viewport/info/oneVertex': 'Vertex',
'viewport/info/oneTriangle': 'Triangle',
'viewport/info/objects': 'Objects',
'viewport/info/vertices': 'Vertices',
'viewport/info/triangles': 'Triangles',
Expand Down Expand Up @@ -703,6 +706,9 @@ function Strings( config ) {
'viewport/controls/grid': 'Grille',
'viewport/controls/helpers': 'Helpers',

'viewport/info/oneObject': 'Objet',
'viewport/info/oneVertex': 'Sommet',
'viewport/info/oneTriangle': 'Triangle',
'viewport/info/objects': 'Objets',
'viewport/info/vertices': 'Sommets',
'viewport/info/triangles': 'Triangles',
Expand Down Expand Up @@ -1056,6 +1062,9 @@ function Strings( config ) {
'viewport/controls/grid': '网格',
'viewport/controls/helpers': '辅助',

'viewport/info/oneObject': '物体',
'viewport/info/oneVertex': '顶点',
'viewport/info/oneTriangle': '三角形',
'viewport/info/objects': '物体',
'viewport/info/vertices': '顶点',
'viewport/info/triangles': '三角形',
Expand Down Expand Up @@ -1409,6 +1418,9 @@ function Strings( config ) {
'viewport/controls/grid': 'グリッド',
'viewport/controls/helpers': 'オーバーレイ表示',

'viewport/info/oneObject': 'オブジェクト',
'viewport/info/oneVertex': '頂点',
'viewport/info/oneTriangle': '三角形',
'viewport/info/objects': 'オブジェクト',
'viewport/info/vertices': '頂点',
'viewport/info/triangles': '三角形',
Expand Down
23 changes: 19 additions & 4 deletions editor/js/Viewport.Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ function ViewportInfo( editor ) {
container.setColor( '#fff' );
container.setTextTransform( 'lowercase' );

const objectsText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' );
const objectsText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' );
const verticesText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' );
const trianglesText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' );
const frametimeText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' );

container.add( objectsText, new UIText( strings.getKey( 'viewport/info/objects' ) ), new UIBreak() );
container.add( verticesText, new UIText( strings.getKey( 'viewport/info/vertices' ) ), new UIBreak() );
container.add( trianglesText, new UIText( strings.getKey( 'viewport/info/triangles' ) ), new UIBreak() );
const objectsUnitText = new UIText( strings.getKey( 'viewport/info/objects' ) );
const verticesUnitText = new UIText( strings.getKey( 'viewport/info/vertices' ) );
const trianglesUnitText = new UIText( strings.getKey( 'viewport/info/triangles' ) );

container.add( objectsText, objectsUnitText, new UIBreak() );
container.add( verticesText, verticesUnitText, new UIBreak() );
container.add( trianglesText, trianglesUnitText, new UIBreak() );
container.add( frametimeText, new UIText( strings.getKey( 'viewport/info/rendertime' ) ), new UIBreak() );

signals.objectAdded.add( update );
Expand Down Expand Up @@ -75,6 +79,17 @@ function ViewportInfo( editor ) {
verticesText.setValue( vertices.format() );
trianglesText.setValue( triangles.format() );

const pluralRules = new Intl.PluralRules( editor.config.getKey( 'language' ) );

const objectsStringKey = ( pluralRules.select( objects ) === 'one' ) ? 'viewport/info/oneObject' : 'viewport/info/objects';
objectsUnitText.setValue( strings.getKey( objectsStringKey ) );

const verticesStringKey = ( pluralRules.select( vertices ) === 'one' ) ? 'viewport/info/oneVertex' : 'viewport/info/vertices';
verticesUnitText.setValue( strings.getKey( verticesStringKey ) );

const trianglesStringKey = ( pluralRules.select( triangles ) === 'one' ) ? 'viewport/info/oneTriangle' : 'viewport/info/triangles';
trianglesUnitText.setValue( strings.getKey( trianglesStringKey ) );

}

function updateFrametime( frametime ) {
Expand Down
Loading