// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: Dec 01, 2006 // // // // // // // localizedPanelLabel( string $englishPanelLabel ) // // // When running Maya in a localized environment, panel // and layout names are also localized and could cause // scripts relying on English names to behave differently. // // Use this procedure to obtain the localized versions of // panel labels like "Top View" and "Persp View", window // names like "Outliner" and "Graph Editor", and configuration/layout // names like "Persp/Outliner" and "Three Panes Stacked". // // // string: the localized version of the label passed in. // // If localizedPanelLabel() is passed a label for which no // localized label is defined, the returned result is the unchanged // input string. // // // // This command returns a non-null result when running in English. // // // $panel = `getPanel -withLabel "Graph Editor"`; // // Result: graphEditor1 // // // // But the same command returns a null result when running in another language. // // // $panel = `getPanel -withLabel "Graph Editor"`; // // Result: // // // // In order to find the graphEditor panel by its label, "getPanel -withLabel" // // must be passed the name of the Graph Editor in the localized language. But // // hard-coding the localized name for one language means the script will fail // // for other localizations, so one way to guarantee consistent script behaviour // // across languages is to use localizedPanelLabel(). // // // $panel = `getPanel -withLabel (localizedPanelLabel("Graph Editor"))`; // // Result: graphEditor1 // // // // // Procedure Name: // localizedPanelLabel // // Description: // Returns the localized panel label. // // Input Arguments: // The english version of the panel label. // // Return Value: // The localized version of the panel label. // global proc string[] localizedPanelLabels() { global string $gPanelLabels[]; if( size( $gPanelLabels ) ) { return $gPanelLabels; } $gPanelLabels = { // Model Panels "Top View", (uiRes("m_localizedPanelLabel.kTopView")) ,"Side View", (uiRes("m_localizedPanelLabel.kSideView")) ,"Front View", (uiRes("m_localizedPanelLabel.kFrontView")) ,"Persp View", (uiRes("m_localizedPanelLabel.kPerspView")) ,"Top Panel", (uiRes("m_localizedPanelLabel.kTopPanel")) ,"Front Panel", (uiRes("m_localizedPanelLabel.kFrontPanel")) ,"Side Panel", (uiRes("m_localizedPanelLabel.kSidePanel")) ,"Persp Panel", (uiRes("m_localizedPanelLabel.kPerspPanel")) ,"Model Panel", (uiRes("m_localizedPanelLabel.kModelPanel")) ,"Perspective", (uiRes("m_localizedPanelLabel.kPerspective")) ,"Single Perspective", (uiRes("m_localizedPanelLabel.kSinglePerspective")) ,"viewPanes", (uiRes("m_localizedPanelLabel.kViewPanes")) // Model[l]ing Toolkit (NEX) specific views ,"Left View", (uiRes("m_localizedPanelLabel.kLeftView")) ,"Right View", (uiRes("m_localizedPanelLabel.kRightView")) ,"Back View", (uiRes("m_localizedPanelLabel.kBackView")) ,"Bottom View", (uiRes("m_localizedPanelLabel.kBottomView")) // Relationship Editor ,"Relationship Editor", (uiRes("m_localizedPanelLabel.kRelationshipEditor")) ,"Relationship Panel", (uiRes("m_localizedPanelLabel.kRelationshipEditor")) // Hypershade ,"Hypershade", (uiRes("m_localizedPanelLabel.kHypershade")) ,"Hyper Shade Panel", (uiRes("m_localizedPanelLabel.kHypershade")) // Visor ,"Visor", (uiRes("m_localizedPanelLabel.kVisor")) ,"Visor Panel", (uiRes("m_localizedPanelLabel.kVisor")) // Time Editor ,"Time Editor", (uiRes("m_localizedPanelLabel.kTimeEditor")) ,"Time Editor Panel", (uiRes("m_localizedPanelLabel.kTimeEditor")) // Trax Editor ,"Trax Editor", (uiRes("m_localizedPanelLabel.kTraxEditor")) ,"Clip Editor Panel", (uiRes("m_localizedPanelLabel.kTraxEditor")) ,"Camera Sequencer", (uiRes("m_localizedPanelLabel.kSequencer")) ,"Shot Playlist", (uiRes("m_localizedPanelLabel.kShotPlaylist")) ,"Shot Playlist Panel", (uiRes("m_localizedPanelLabel.kShotPlaylist")) ,"Sequence Editor Panel", (uiRes("m_localizedPanelLabel.kSequencer")) // Reference Editor ,"Reference Editor", (uiRes("m_localizedPanelLabel.kRefEd")) ,"Reference Editor Panel", (uiRes("m_localizedPanelLabel.kRefEd")) // Web Browser ,"Web Browser", (uiRes("m_localizedPanelLabel.kWebBrowser")) ,"Web Browser Panel", (uiRes("m_localizedPanelLabel.kWebBrowser")) // Paint Effects ,"Paint Effects", (uiRes("m_localizedPanelLabel.kPaintEffects")) ,"Dyn Paint Scripted Panel Type", (uiRes("m_localizedPanelLabel.kPaintEffects")) // Outliner ,"Outliner", (uiRes("m_localizedPanelLabel.kOutliner")) ,"Outliner Panel", (uiRes("m_localizedPanelLabel.kOutliner")) // Asset Browser ,"Content Browser", (uiRes("m_localizedPanelLabel.kContentBrowser")) ,"Content Browser Panel", (uiRes("m_localizedPanelLabel.kContentBrowser")) // Graph Editor ,"Graph Editor", (uiRes("m_localizedPanelLabel.kGraphEditor")) // profiler Tool ,"Profiler Tool", (uiRes("m_localizedPanelLabel.kProfilerTool")) ,"Profiler Panel", (uiRes("m_localizedPanelLabel.kProfilerPanel")) // Dope Sheet ,"Dope Sheet", (uiRes("m_localizedPanelLabel.kDopeSheet")) ,"Dope Sheet Panel", (uiRes("m_localizedPanelLabel.kDopeSheet")) // Hypergraph ,"Hypergraph", (uiRes("m_localizedPanelLabel.kHypergraph")) ,"Hyper Graph Panel", (uiRes("m_localizedPanelLabel.kHypergraph")) ,"Hypergraph Hierarchy", (uiRes("m_localizedPanelLabel.kHypergraphHierarchy")) ,"Hypergraph InputOutput", (uiRes("m_localizedPanelLabel.kHypergraphInputOutput")) // Node Editor ,"Node Editor", (uiRes("m_localizedPanelLabel.kNodeEditor")) ,"Node Editor Panel", (uiRes("m_localizedPanelLabel.kNodeEditor")) ,"Node Editor InputOutput", (uiRes("m_localizedPanelLabel.kNodeEditorInputOutput")) // Create Node ,"Create Node", (uiRes("m_localizedPanelLabel.kCreateNode")) ,"Create Node Panel", (uiRes("m_localizedPanelLabel.kCreateNode")) // Dynamic Relationships ,"Dynamic Relationships", (uiRes("m_localizedPanelLabel.kDynamicRelationships")) ,"Dyn Rel Ed Panel", (uiRes("m_localizedPanelLabel.kDynamicRelationships")) // Render View ,"Render View", (uiRes("m_localizedPanelLabel.kRenderView")) ,"Render Window Panel", (uiRes("m_localizedPanelLabel.kRenderView")) // UV Texture Editor ,"UV Editor", (uiRes("m_localizedPanelLabel.kUVEditor")) ,"UV Texture Editor", (uiRes("m_localizedPanelLabel.kUVEditor")) ,"Poly Texture Placement Panel", (uiRes("m_localizedPanelLabel.kUVEditor")) // UV Toolkit ,"UV Toolkit", (uiRes("m_localizedPanelLabel.kUVToolkit")) // Multilister ,"Multilister", (uiRes("m_localizedPanelLabel.kMultilister")) ,"Multi Lister Panel", (uiRes("m_localizedPanelLabel.kMultilister")) // Blend Shape ,"Blend Shape", (uiRes("m_localizedPanelLabel.kBlendShape")) ,"Blend Shape Panel", (uiRes("m_localizedPanelLabel.kBlendShape")) // Shape Editor ,"Shape Editor", (uiRes("m_localizedPanelLabel.kShapeEditor")) ,"Shape Panel", (uiRes("m_localizedPanelLabel.kShapeEditor")) // Pose Editor ,"Pose Editor", (uiRes("m_localizedPanelLabel.kPoseEditor")) ,"Pose Panel", (uiRes("m_localizedPanelLabel.kPoseEditor")) // Devices ,"Devices", (uiRes("m_localizedPanelLabel.kDevices")) ,"Device Panel", (uiRes("m_localizedPanelLabel.kDevices")) // Component Editor ,"Component Editor", (uiRes("m_localizedPanelLabel.kComponentEd")) ,"Component Editor Panel", (uiRes("m_localizedPanelLabel.kComponentEd")) // Script Editor ,"Script Editor", (uiRes("m_localizedPanelLabel.kScriptEditor")) ,"Script Editor Panel", (uiRes("m_localizedPanelLabel.kScriptEditor")) // Polygon Selection Constraints ,"Polygon Selection Constraints", (uiRes("m_localizedPanelLabel.kPolySelectionConstraints")) ,"Poly Selection Constraint Panel", (uiRes("m_localizedPanelLabel.kPolySelectionConstraintPanel")) // Misc panels ,"Shading Group Editor", (uiRes("m_localizedPanelLabel.kShadingGroupEditor")) ,"Set Editor", (uiRes("m_localizedPanelLabel.kSetEditor")) ,"Blind Data Editor", (uiRes("m_localizedPanelLabel.kBlindDataEditor")) // Combos ,"Front/Persp", (uiRes("m_localizedPanelLabel.kFrontPerspView")) ,"Persp/Graph", (uiRes("m_localizedPanelLabel.kPerspGraph")) ,"Hypershade/Persp", (uiRes("m_localizedPanelLabel.kHypershadePersp")) ,"Persp/Graph/Hypergraph", (uiRes("m_localizedPanelLabel.kPerspGraphHypergraph")) ,"Persp/UV Editor", (uiRes("m_localizedPanelLabel.kPerspUVEditor")) ,"Persp/UV Texture Editor", (uiRes("m_localizedPanelLabel.kPerspUVEditor")) ,"Hypershade/Render/Persp" , (uiRes("m_localizedPanelLabel.kHypershadeRenderPersp")) ,"Hypershade/Outliner/Persp", (uiRes("m_localizedPanelLabel.kHypershadeOutlinerPersp")) ,"Persp/Graph/Outliner", (uiRes("m_localizedPanelLabel.kPerspGraphOutliner")) ,"Persp/Relationship Editor", (uiRes("m_localizedPanelLabel.kPerspRelationshipEditor")) ,"Persp/Hypergraph", (uiRes("m_localizedPanelLabel.kPerspHypergraph")) ,"Web Browser/Persp", (uiRes("m_localizedPanelLabel.kWebBrowserPersp")) ,"Persp/Trax", (uiRes("m_localizedPanelLabel.kPerspTrax")) ,"Persp/Camera Sequencer", (uiRes("m_localizedPanelLabel.kPerspSequencer")) ,"Persp/Trax/Outliner", (uiRes("m_localizedPanelLabel.kPerspTraxOutliner")) ,"Hypershade/Render/Persp Vertical", (uiRes("m_localizedPanelLabel.kHypershadeRenderPerspVertical")) ,"Perspective View", (uiRes("m_localizedPanelLabel.kPerspectiveView")) ,"Script Editor/Persp", (uiRes("m_localizedPanelLabel.kScriptEditorPersp")) ,"Stereo", (uiRes("m_localizedPanelLabel.kStereoCameraName")) ,"Stereo Persp", (uiRes("m_localizedPanelLabel.kStereoPanelStereoPersp")) ,"Stereo Persp/Outliner", (uiRes("m_localizedPanelLabel.kStereoPanelStereoPerspOutliner")) // Layouts ,"Current Layout", (uiRes("m_localizedPanelLabel.kCurrentLayout")) ,"Single Perspective View", (uiRes("m_localizedPanelLabel.kSinglePerspectiveView")) ,"Four View", (uiRes("m_localizedPanelLabel.kFourView")) ,"Single Pane", (uiRes("m_localizedPanelLabel.kSinglePane")) ,"Two Panes Side by Side", (uiRes("m_localizedPanelLabel.kTwoPanesSidebySide")) ,"Two Panes Stacked", (uiRes("m_localizedPanelLabel.kTwoPanesStacked")) ,"Three Panes Split Top", (uiRes("m_localizedPanelLabel.kThreePanesSplitTop")) ,"Three Panes Split Left", (uiRes("m_localizedPanelLabel.kThreePanesSplitLeft")) ,"Three Panes Split Bottom", (uiRes("m_localizedPanelLabel.kThreePanesSplitBottom")) ,"Three Panes Split Right", (uiRes("m_localizedPanelLabel.kThreePanesSplitRight")) ,"Four Panes", (uiRes("m_localizedPanelLabel.kFourPanes")) ,"Three Panes Stacked", (uiRes("m_localizedPanelLabel.kThreePanesStacked")) ,"Three Panes Side by Side", (uiRes("m_localizedPanelLabel.kThreePanesSidebySide")) ,"Four Panes Split Top", (uiRes("m_localizedPanelLabel.kFourPanesSplitTop")) ,"Four Panes Split Left", (uiRes("m_localizedPanelLabel.kFourPanesSplitLeft")) ,"Four Panes Split Bottom", (uiRes("m_localizedPanelLabel.kFourPanesSplitBottom")) ,"Four Panes Split Right", (uiRes("m_localizedPanelLabel.kFourPanesSplitRight")) ,"Four Panes Stacked", (uiRes("m_localizedPanelLabel.kFourPanesStacked")) ,"Four Panes Side by Side", (uiRes("m_localizedPanelLabel.kFourPanesSidebySide")) ,"Panel Configuration", (uiRes("m_localizedPanelLabel.kPanelConfig")) }; return $gPanelLabels; } global proc string[] labelBaseAndSuffix( string $label ) // // Description: // Hypergraph panels have a numeric suffix, as do torn // off model panels and new panels, so we have to // remember it, strip it off before the translation, and // then add it back after the translation... // // $label could be localized, but number matching using // MEL regexp should be OK. // { string $baseLabel = `match ".*[^0-9]+" $label`; string $suffix; if( $baseLabel != $label ) { $suffix = `match "[0-9]*$" $label`; $baseLabel = `strip $baseLabel`; } string $results[]; $results[0] = $baseLabel; $results[1] = $suffix; return $results; } global proc string localizedPanelLabel(string $panelLabelEN) { string $panelLabel; string $results[] = `labelBaseAndSuffix $panelLabelEN`; string $baseLabel = $results[0]; string $suffix = $results[1]; string $labels[] = localizedPanelLabels(); int $foundIt = false; int $i, $count = size( $labels ); for( $i = 0; $i < $count-1; $i+=2 ) { if( $baseLabel == $labels[$i] ) { $panelLabel = $labels[$i+1]; $foundIt = true; break; } } // If the panel name had a suffix, add it back now. // if( size( $suffix ) ) { $panelLabel += $suffix; } // If we couldn't find a match, just return what was // passed in. // if( !$foundIt ) { $panelLabel = $panelLabelEN; uiToMelMsg( "localizedPanelLabel", $panelLabelEN, 0 ); } return $panelLabel; }