From cb57855de58f733d10e2099c7f00dfab97146bcc Mon Sep 17 00:00:00 2001 From: ycw Date: Fri, 3 May 2024 03:59:53 +0800 Subject: [PATCH 1/2] localize the prompts --- editor/index.html | 2 +- editor/js/History.js | 6 ++--- editor/js/Menubar.Examples.js | 2 +- editor/js/Menubar.File.js | 6 ++--- editor/js/Sidebar.Script.js | 2 +- editor/js/Sidebar.Settings.History.js | 4 ++-- editor/js/Strings.js | 32 +++++++++++++++++++++++++++ 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/editor/index.html b/editor/index.html index 7dc14f0936b57f..8210e9fd167773 100644 --- a/editor/index.html +++ b/editor/index.html @@ -226,7 +226,7 @@ const file = hash.slice( 6 ); - if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) { + if ( confirm( editor.strings.getKey( '[prompt]/file/open' ) ) ) { const loader = new THREE.FileLoader(); loader.crossOrigin = ''; diff --git a/editor/js/History.js b/editor/js/History.js index 519140e164a703..a52cfbbae9e864 100644 --- a/editor/js/History.js +++ b/editor/js/History.js @@ -88,7 +88,7 @@ class History { if ( this.historyDisabled ) { - alert( 'Undo/Redo disabled while scene is playing.' ); + alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); return; } @@ -123,7 +123,7 @@ class History { if ( this.historyDisabled ) { - alert( 'Undo/Redo disabled while scene is playing.' ); + alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); return; } @@ -241,7 +241,7 @@ class History { if ( this.historyDisabled ) { - alert( 'Undo/Redo disabled while scene is playing.' ); + alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); return; } diff --git a/editor/js/Menubar.Examples.js b/editor/js/Menubar.Examples.js index f9a78429c74433..b60eb94580188c 100644 --- a/editor/js/Menubar.Examples.js +++ b/editor/js/Menubar.Examples.js @@ -41,7 +41,7 @@ function MenubarExamples( editor ) { option.setTextContent( strings.getKey( item.title ) ); option.onClick( function () { - if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) { + if ( confirm( strings.getKey( '[prompt]/file/open' ) ) ) { loader.load( 'examples/' + item.file, function ( text ) { diff --git a/editor/js/Menubar.File.js b/editor/js/Menubar.File.js index 3416b468d31216..ab910ff5d9cd06 100644 --- a/editor/js/Menubar.File.js +++ b/editor/js/Menubar.File.js @@ -26,7 +26,7 @@ function MenubarFile( editor ) { option.setTextContent( strings.getKey( 'menubar/file/new' ) ); option.onClick( function () { - if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) { + if ( confirm( strings.getKey( '[prompt]/file/open' ) ) ) { editor.clear(); @@ -81,7 +81,7 @@ function MenubarFile( editor ) { if ( object === null || object.isMesh === undefined ) { - alert( 'No mesh selected' ); + alert( strings.getKey( '[prompt]/file/export/noMeshSelected' ) ); return; } @@ -181,7 +181,7 @@ function MenubarFile( editor ) { if ( object === null ) { - alert( 'No object selected.' ); + alert( strings.getKey( '[prompt]/file/export/noObjectSelected' ) ); return; } diff --git a/editor/js/Sidebar.Script.js b/editor/js/Sidebar.Script.js index a6945e9f0fb9d6..decd0da7a4b499 100644 --- a/editor/js/Sidebar.Script.js +++ b/editor/js/Sidebar.Script.js @@ -81,7 +81,7 @@ function SidebarScript( editor ) { remove.setMarginLeft( '4px' ); remove.onClick( function () { - if ( confirm( 'Are you sure?' ) ) { + if ( confirm( strings.getKey( '[prompt]/script/remove' ) ) ) { editor.execute( new RemoveScriptCommand( editor, editor.selected, script ) ); diff --git a/editor/js/Sidebar.Settings.History.js b/editor/js/Sidebar.Settings.History.js index 2dc43828f9cbe0..3f19f2be62104d 100644 --- a/editor/js/Sidebar.Settings.History.js +++ b/editor/js/Sidebar.Settings.History.js @@ -25,7 +25,7 @@ function SidebarSettingsHistory( editor ) { if ( value ) { - alert( 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.' ); + alert( strings.getKey( '[prompt]/history/preserve' ) ); const lastUndoCmd = history.undos[ history.undos.length - 1 ]; const lastUndoId = ( lastUndoCmd !== undefined ) ? lastUndoCmd.id : 0; @@ -63,7 +63,7 @@ function SidebarSettingsHistory( editor ) { const option = new UIButton( strings.getKey( 'sidebar/history/clear' ) ); option.onClick( function () { - if ( confirm( 'The Undo/Redo History will be cleared. Are you sure?' ) ) { + if ( confirm( strings.getKey( '[prompt]/history/clear' ) ) ) { editor.history.clear(); diff --git a/editor/js/Strings.js b/editor/js/Strings.js index 1c2ed6c7c4e30b..f8994fc7d4ab89 100644 --- a/editor/js/Strings.js +++ b/editor/js/Strings.js @@ -6,6 +6,14 @@ function Strings( config ) { en: { + '[prompt]/file/open': 'Any unsaved data will be lost. Are you sure?', + '[prompt]/file/export/noMeshSelected': 'No Mesh selected!', + '[prompt]/file/export/noObjectSelected': 'No Object selected!', + '[prompt]/script/remove': 'Are you sure?', + '[prompt]/history/clear': 'The Undo/Redo History will be cleared. Are you sure?', + '[prompt]/history/preserve': 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.', + '[prompt]/history/forbid': 'Undo/Redo disabled while scene is playing.', + 'menubar/file': 'File', 'menubar/file/new': 'New', 'menubar/file/import': 'Import', @@ -362,6 +370,14 @@ function Strings( config ) { fr: { + '[prompt]/file/open': 'Toutes les données non enregistrées seront perdues Êtes-vous sûr ?', + '[prompt]/file/export/noMeshSelected': 'Aucun maillage sélectionné !', + '[prompt]/file/export/noObjectSelected': 'Aucun objet sélectionné !', + '[prompt]/script/remove': 'Es-tu sûr?', + '[prompt]/history/clear': 'L\'historique d\'annulation/rétablissement sera effacé Êtes-vous sûr ?', + '[prompt]/history/preserve': 'L\'histoire sera conservée entre les sessions.\nCela peut avoir un impact sur les performances lors de la manipulation des textures.', + '[prompt]/history/forbid': 'Les fonctions Annuler/Rétablir sont désactivées pendant la lecture de la scène.', + 'menubar/file': 'Fichier', 'menubar/file/new': 'Nouveau', 'menubar/file/import': 'Importer', @@ -718,6 +734,14 @@ function Strings( config ) { zh: { + '[prompt]/file/open': '您确定吗?未保存的数据将会丢失。', + '[prompt]/file/export/noMeshSelected': '未选择网格!', + '[prompt]/file/export/noObjectSelected': '未选择对象!', + '[prompt]/script/remove': '你确定吗?', + '[prompt]/history/clear': '撤销/重做历史记录将被清除。您确定吗?', + '[prompt]/history/preserve': '历史将在会话之间保留。\n这可能会影响在处理纹理时的性能。', + '[prompt]/history/forbid': '在播放场景时,撤消/重做被禁用。', + 'menubar/file': '文件', 'menubar/file/new': '新建', 'menubar/file/import': '导入', @@ -1074,6 +1098,14 @@ function Strings( config ) { ja: { + '[prompt]/file/open': '保存されていないデータは失われます。 本気ですか?', + '[prompt]/file/export/noMeshSelected': 'メッシュが選択されていません!', + '[prompt]/file/export/noObjectSelected': 'オブジェクトが選択されていません!', + '[prompt]/script/remove': '本気ですか?', + '[prompt]/history/clear': '元に戻す/やり直しの履歴が消去されます。 本気ですか?', + '[prompt]/history/preserve': '履歴はセッションをまたいで保存されます。\nこれは、テクスチャを操作する際のパフォーマンスに影響を与える可能性があります。', + '[prompt]/history/forbid': 'シーンの再生中は元に戻す/やり直しは無効になります。', + 'menubar/file': 'ファイル', 'menubar/file/new': '新規', 'menubar/file/import': 'インポート', From c6e521bc3f490b3b68cac99f5e935cfe1a4af60a Mon Sep 17 00:00:00 2001 From: ycw Date: Fri, 3 May 2024 18:13:56 +0800 Subject: [PATCH 2/2] no brackets --- editor/index.html | 2 +- editor/js/History.js | 6 +-- editor/js/Menubar.Examples.js | 2 +- editor/js/Menubar.File.js | 6 +-- editor/js/Sidebar.Script.js | 2 +- editor/js/Sidebar.Settings.History.js | 4 +- editor/js/Strings.js | 56 +++++++++++++-------------- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/editor/index.html b/editor/index.html index 8210e9fd167773..d40ae58eabb930 100644 --- a/editor/index.html +++ b/editor/index.html @@ -226,7 +226,7 @@ const file = hash.slice( 6 ); - if ( confirm( editor.strings.getKey( '[prompt]/file/open' ) ) ) { + if ( confirm( editor.strings.getKey( 'prompt/file/open' ) ) ) { const loader = new THREE.FileLoader(); loader.crossOrigin = ''; diff --git a/editor/js/History.js b/editor/js/History.js index a52cfbbae9e864..b0f69e71650c86 100644 --- a/editor/js/History.js +++ b/editor/js/History.js @@ -88,7 +88,7 @@ class History { if ( this.historyDisabled ) { - alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); + alert( this.editor.strings.getKey( 'prompt/history/forbid' ) ); return; } @@ -123,7 +123,7 @@ class History { if ( this.historyDisabled ) { - alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); + alert( this.editor.strings.getKey( 'prompt/history/forbid' ) ); return; } @@ -241,7 +241,7 @@ class History { if ( this.historyDisabled ) { - alert( this.editor.strings.getKey( '[prompt]/history/forbid' ) ); + alert( this.editor.strings.getKey( 'prompt/history/forbid' ) ); return; } diff --git a/editor/js/Menubar.Examples.js b/editor/js/Menubar.Examples.js index b60eb94580188c..fc50f845b20982 100644 --- a/editor/js/Menubar.Examples.js +++ b/editor/js/Menubar.Examples.js @@ -41,7 +41,7 @@ function MenubarExamples( editor ) { option.setTextContent( strings.getKey( item.title ) ); option.onClick( function () { - if ( confirm( strings.getKey( '[prompt]/file/open' ) ) ) { + if ( confirm( strings.getKey( 'prompt/file/open' ) ) ) { loader.load( 'examples/' + item.file, function ( text ) { diff --git a/editor/js/Menubar.File.js b/editor/js/Menubar.File.js index ab910ff5d9cd06..d136ca9ca596e8 100644 --- a/editor/js/Menubar.File.js +++ b/editor/js/Menubar.File.js @@ -26,7 +26,7 @@ function MenubarFile( editor ) { option.setTextContent( strings.getKey( 'menubar/file/new' ) ); option.onClick( function () { - if ( confirm( strings.getKey( '[prompt]/file/open' ) ) ) { + if ( confirm( strings.getKey( 'prompt/file/open' ) ) ) { editor.clear(); @@ -81,7 +81,7 @@ function MenubarFile( editor ) { if ( object === null || object.isMesh === undefined ) { - alert( strings.getKey( '[prompt]/file/export/noMeshSelected' ) ); + alert( strings.getKey( 'prompt/file/export/noMeshSelected' ) ); return; } @@ -181,7 +181,7 @@ function MenubarFile( editor ) { if ( object === null ) { - alert( strings.getKey( '[prompt]/file/export/noObjectSelected' ) ); + alert( strings.getKey( 'prompt/file/export/noObjectSelected' ) ); return; } diff --git a/editor/js/Sidebar.Script.js b/editor/js/Sidebar.Script.js index decd0da7a4b499..fc1b8fb6f8b5f1 100644 --- a/editor/js/Sidebar.Script.js +++ b/editor/js/Sidebar.Script.js @@ -81,7 +81,7 @@ function SidebarScript( editor ) { remove.setMarginLeft( '4px' ); remove.onClick( function () { - if ( confirm( strings.getKey( '[prompt]/script/remove' ) ) ) { + if ( confirm( strings.getKey( 'prompt/script/remove' ) ) ) { editor.execute( new RemoveScriptCommand( editor, editor.selected, script ) ); diff --git a/editor/js/Sidebar.Settings.History.js b/editor/js/Sidebar.Settings.History.js index 3f19f2be62104d..d7ad619f52c30a 100644 --- a/editor/js/Sidebar.Settings.History.js +++ b/editor/js/Sidebar.Settings.History.js @@ -25,7 +25,7 @@ function SidebarSettingsHistory( editor ) { if ( value ) { - alert( strings.getKey( '[prompt]/history/preserve' ) ); + alert( strings.getKey( 'prompt/history/preserve' ) ); const lastUndoCmd = history.undos[ history.undos.length - 1 ]; const lastUndoId = ( lastUndoCmd !== undefined ) ? lastUndoCmd.id : 0; @@ -63,7 +63,7 @@ function SidebarSettingsHistory( editor ) { const option = new UIButton( strings.getKey( 'sidebar/history/clear' ) ); option.onClick( function () { - if ( confirm( strings.getKey( '[prompt]/history/clear' ) ) ) { + if ( confirm( strings.getKey( 'prompt/history/clear' ) ) ) { editor.history.clear(); diff --git a/editor/js/Strings.js b/editor/js/Strings.js index f8994fc7d4ab89..351219178663ac 100644 --- a/editor/js/Strings.js +++ b/editor/js/Strings.js @@ -6,13 +6,13 @@ function Strings( config ) { en: { - '[prompt]/file/open': 'Any unsaved data will be lost. Are you sure?', - '[prompt]/file/export/noMeshSelected': 'No Mesh selected!', - '[prompt]/file/export/noObjectSelected': 'No Object selected!', - '[prompt]/script/remove': 'Are you sure?', - '[prompt]/history/clear': 'The Undo/Redo History will be cleared. Are you sure?', - '[prompt]/history/preserve': 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.', - '[prompt]/history/forbid': 'Undo/Redo disabled while scene is playing.', + 'prompt/file/open': 'Any unsaved data will be lost. Are you sure?', + 'prompt/file/export/noMeshSelected': 'No Mesh selected!', + 'prompt/file/export/noObjectSelected': 'No Object selected!', + 'prompt/script/remove': 'Are you sure?', + 'prompt/history/clear': 'The Undo/Redo History will be cleared. Are you sure?', + 'prompt/history/preserve': 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.', + 'prompt/history/forbid': 'Undo/Redo disabled while scene is playing.', 'menubar/file': 'File', 'menubar/file/new': 'New', @@ -370,13 +370,13 @@ function Strings( config ) { fr: { - '[prompt]/file/open': 'Toutes les données non enregistrées seront perdues Êtes-vous sûr ?', - '[prompt]/file/export/noMeshSelected': 'Aucun maillage sélectionné !', - '[prompt]/file/export/noObjectSelected': 'Aucun objet sélectionné !', - '[prompt]/script/remove': 'Es-tu sûr?', - '[prompt]/history/clear': 'L\'historique d\'annulation/rétablissement sera effacé Êtes-vous sûr ?', - '[prompt]/history/preserve': 'L\'histoire sera conservée entre les sessions.\nCela peut avoir un impact sur les performances lors de la manipulation des textures.', - '[prompt]/history/forbid': 'Les fonctions Annuler/Rétablir sont désactivées pendant la lecture de la scène.', + 'prompt/file/open': 'Toutes les données non enregistrées seront perdues Êtes-vous sûr ?', + 'prompt/file/export/noMeshSelected': 'Aucun maillage sélectionné !', + 'prompt/file/export/noObjectSelected': 'Aucun objet sélectionné !', + 'prompt/script/remove': 'Es-tu sûr?', + 'prompt/history/clear': 'L\'historique d\'annulation/rétablissement sera effacé Êtes-vous sûr ?', + 'prompt/history/preserve': 'L\'histoire sera conservée entre les sessions.\nCela peut avoir un impact sur les performances lors de la manipulation des textures.', + 'prompt/history/forbid': 'Les fonctions Annuler/Rétablir sont désactivées pendant la lecture de la scène.', 'menubar/file': 'Fichier', 'menubar/file/new': 'Nouveau', @@ -734,13 +734,13 @@ function Strings( config ) { zh: { - '[prompt]/file/open': '您确定吗?未保存的数据将会丢失。', - '[prompt]/file/export/noMeshSelected': '未选择网格!', - '[prompt]/file/export/noObjectSelected': '未选择对象!', - '[prompt]/script/remove': '你确定吗?', - '[prompt]/history/clear': '撤销/重做历史记录将被清除。您确定吗?', - '[prompt]/history/preserve': '历史将在会话之间保留。\n这可能会影响在处理纹理时的性能。', - '[prompt]/history/forbid': '在播放场景时,撤消/重做被禁用。', + 'prompt/file/open': '您确定吗?未保存的数据将会丢失。', + 'prompt/file/export/noMeshSelected': '未选择网格!', + 'prompt/file/export/noObjectSelected': '未选择对象!', + 'prompt/script/remove': '你确定吗?', + 'prompt/history/clear': '撤销/重做历史记录将被清除。您确定吗?', + 'prompt/history/preserve': '历史将在会话之间保留。\n这可能会影响在处理纹理时的性能。', + 'prompt/history/forbid': '在播放场景时,撤消/重做被禁用。', 'menubar/file': '文件', 'menubar/file/new': '新建', @@ -1098,13 +1098,13 @@ function Strings( config ) { ja: { - '[prompt]/file/open': '保存されていないデータは失われます。 本気ですか?', - '[prompt]/file/export/noMeshSelected': 'メッシュが選択されていません!', - '[prompt]/file/export/noObjectSelected': 'オブジェクトが選択されていません!', - '[prompt]/script/remove': '本気ですか?', - '[prompt]/history/clear': '元に戻す/やり直しの履歴が消去されます。 本気ですか?', - '[prompt]/history/preserve': '履歴はセッションをまたいで保存されます。\nこれは、テクスチャを操作する際のパフォーマンスに影響を与える可能性があります。', - '[prompt]/history/forbid': 'シーンの再生中は元に戻す/やり直しは無効になります。', + 'prompt/file/open': '保存されていないデータは失われます。 本気ですか?', + 'prompt/file/export/noMeshSelected': 'メッシュが選択されていません!', + 'prompt/file/export/noObjectSelected': 'オブジェクトが選択されていません!', + 'prompt/script/remove': '本気ですか?', + 'prompt/history/clear': '元に戻す/やり直しの履歴が消去されます。 本気ですか?', + 'prompt/history/preserve': '履歴はセッションをまたいで保存されます。\nこれは、テクスチャを操作する際のパフォーマンスに影響を与える可能性があります。', + 'prompt/history/forbid': 'シーンの再生中は元に戻す/やり直しは無効になります。', 'menubar/file': 'ファイル', 'menubar/file/new': '新規',