Author: kmachalkova Date: Wed Dec 3 15:52:38 2008 New Revision: 53851 URL: http://svn.opensuse.org/viewcvs/yast?rev=53851&view=rev Log: Translate CC groups and module names (#450494) - translations are now in desktop_translations.mo Modified: trunk/yast2/library/desktop/src/Desktop.ycp Modified: trunk/yast2/library/desktop/src/Desktop.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/desktop/src/Desktop.ycp?rev=53851&r1=53850&r2=53851&view=diff ============================================================================== --- trunk/yast2/library/desktop/src/Desktop.ycp (original) +++ trunk/yast2/library/desktop/src/Desktop.ycp Wed Dec 3 15:52:38 2008 @@ -49,14 +49,17 @@ /** */ -define string ReadLocalizedKey(path keypath, string key) { +define string ReadLocalizedKey(string fname, path keypath, string key) { if(key != "Name" && key != "GenericName") return (string) SCR::Read(add(keypath, key)); string ret = ""; string newkey = ""; + string fallback = (string) SCR::Read(add(keypath, key)); + //check if there are any translation in .desktop file + //that is - Name[$lang_code] if(LanguageFull != nil || LanguageFull != "") { newkey = sformat("%1[%2]", key, LanguageFull); ret = (string) SCR::Read(add(keypath, newkey)); @@ -69,7 +72,17 @@ if(ret != nil && ret != "") return ret; } - return (string) SCR::Read(add(keypath, key)); + //no translations in .desktop, check desktop_translations.mo then + string msgid = sformat("%1(%2): %3", key, fname, fallback ); + ret = dgettext( "desktop_translations", msgid ); + + //probably untranslated - return english name + if(ret == msgid) + { + return fallback; + } + + return ret; } /** @@ -78,6 +91,14 @@ */ global define void Read(list<string> Values) { + string ExtractDesktopFilename( string fullpath ) + { + list <string> path_components = splitstring(fullpath, "/"); + string filename = path_components[ size( path_components) - 1]:""; + + return filename; + } + /* read modules */ map filemap = $[]; path filepath = nil; @@ -102,11 +123,12 @@ foreach(string group, groups, { filemap = $[]; filepath = .yast2.groups.v + group + "Desktop Entry"; + string filename = ExtractDesktopFilename( group ); filemap["Icon"] = SCR::Read(filepath + "Icon"); filemap["SortKey"] = SCR::Read(filepath + "X-SuSE-YaST-SortKey"); filemap["Hidden"] = SCR::Read(filepath + "Hidden"); - filemap["Name"] = ReadLocalizedKey(filepath, "Name"); + filemap["Name"] = ReadLocalizedKey(filename, filepath, "Name"); filemap["modules"] = []; string name = (string) SCR::Read(filepath + "X-SuSE-YaST-Group"); @@ -119,9 +141,11 @@ filemap = $[]; filepath = AgentPath + .v + file + ."Desktop Entry"; list<string> values = (list<string>) SCR::Dir(filepath); + string filename = ExtractDesktopFilename( file ); + if(Values != nil && Values != []) values = Values; foreach(string value, values, { - string ret = ReadLocalizedKey(filepath, value); + string ret = ReadLocalizedKey(filename, filepath, value); if(ret != nil && ret != "") filemap[value] = ret; }); string name = regexpsub(file, "^.*/(.*)\.desktop", "\\1"); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org