// =========================================================================== // 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: September 22, 2006 // // Description: // Helper script to centralize access to localized // plugin resources. // // This behaves in a similar fashion to languageResourcePath, // the main difference is that it has additional search locations // and it does not assume that resource files for plugins are // will always be supplied. // // The procedure takes the name of a resource file and returns a // path to the language-appropriate version of the given file. // If the file does not exist an empty string will be returned. // // The resulting path, if not empty, is guaranteed to point // to the localized version of the file. // global proc string pluginLanguageResourcePath( string $file ) { string $path = ""; int $isLocalized = `about -uiLanguageIsLocalized`; // In non-localized environment, return empty path if( !$isLocalized ) { return $path; } // Get MAYA_PLUG_IN_RESOURCE_PATH for the search path string $searchPath = `getenv("MAYA_PLUG_IN_RESOURCE_PATH")`; if (size($searchPath) > 0) { // Searchpath strings are separated with different // characters depending on the platform. string $pathSep; if (`about -win`) { $pathSep = ";"; } else { $pathSep = ":"; } string $searchArray[] = stringToStringArray($searchPath, $pathSep); // Search for the file // Return value is empty string if path is not found for ( $dir in $searchArray ) { $path = ($dir + "/" + $file); // Did we find the pres resource in one of // the MAYA_PLUG_IN_RESOURCE_PATH folders? if( `filetest -r $path` ) { return $path; } // On MacOS, it might be that the pres resource is actually in // a folder with the lproj extension. Lets check for this case. else if (`about -macOS`) { $path = ($dir + ".lproj/" + $file); if( `filetest -r $path` ) { return $path; } } } } return ""; }