Permalink
Browse files

localization fixes and change Feature Dialog to show values when no l…

…abel is present for a feature or setting
  • Loading branch information...
1 parent 1844dff commit 0e0ec80aa4975bd8f51d6883d261af4cce981164 Keith Stribley committed Jul 29, 2010
View
@@ -84,6 +84,7 @@ find_path(OO_SDK_URE_BIN version.ini versionrc
find_program(UNOPKG unopkg PATHS ENV OFFICE_PROGRAM_PATH /usr/bin
DOC "OpenOffice.org Extension Manager")
find_program(ZIP zip)
+find_program(NATIVE2ASCII native2ascii)
include_directories ("${OO_SDK_INCLUDE}" ${FREETYPE_INCLUDE_DIRS})
@@ -171,6 +172,11 @@ add_test(NAME test_graphiteooouno COMMAND "$<TARGET_FILE:test_graphiteooouno>"
ENVIRONMENT PATH=${OO_SDK_URE_BIN} )
target_link_libraries(test_graphiteooouno graphiteooo)
+add_executable(test_locale2lcid src/test_locale2lcid.cxx)
+add_test(NAME test_locale2lcid COMMAND "$<TARGET_FILE:test_locale2lcid>"
+ ENVIRONMENT PATH=${OO_SDK_URE_BIN} )
+target_link_libraries(test_locale2lcid ${OO_SDK_UNO_SAL})
+
enable_testing()
# just use one sample IDL header since we compile them in one go
@@ -202,9 +208,12 @@ target_link_libraries(test_graphitefontinfo optimized ${GR_RELEASE_LIBRARY})
file(GLOB L10N_FILES RELATIVE ${PROJECT_SOURCE_DIR} dialogs/*.properties l10n/*.txt)
foreach (l10nFile ${L10N_FILES} )
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/${l10nFile}
+ COMMAND ${NATIVE2ASCII} -encoding UTF-8
${PROJECT_SOURCE_DIR}/${l10nFile}
- ${PROJECT_BINARY_DIR}/${l10nFile})
+ ${PROJECT_BINARY_DIR}/${l10nFile}
+ DEPENDS ${PROJECT_SOURCE_DIR}/${l10nFile})
+ set(L10N_ESCAPED_FILES ${L10N_ESCAPED_FILES} ${PROJECT_BINARY_DIR}/${l10nFile})
endforeach (l10nFile ${L10N_FILES})
set(ZIP_FILES
@@ -296,7 +305,7 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/graphiteooo${CMAKE_SHARED_LIBRARY_SUFFIX})
add_custom_target(ooextension ALL COMMAND ${ZIP} ${PROJECT_BINARY_DIR}/graphiteooo_${EXTENSION_PLATFORM}.oxt ${ZIP_FILES}
- WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR} DEPENDS ${L10N_ESCAPED_FILES})
# clean the headers generated from IDL
add_custom_target(idlclean
@@ -312,5 +321,18 @@ add_custom_target(uninstall
COMMAND ${UNOPKG} remove --shared org.sil.graphite.GraphiteOptions
COMMENT install the extension system wide - requires admin permissions)
+add_custom_target(install_user
+ COMMAND ${UNOPKG} add ${PROJECT_BINARY_DIR}/graphiteooo_${EXTENSION_PLATFORM}.oxt
+ COMMENT install the extension system wide - requires admin permissions)
+
+add_custom_target(uninstall_user
+ COMMAND ${UNOPKG} remove org.sil.graphite.GraphiteOptions
+ COMMENT install the extension system wide - requires admin permissions)
+
+add_custom_target(reinstall_user
+ COMMAND ${UNOPKG} remove org.sil.graphite.GraphiteOptions
+ COMMAND ${UNOPKG} add ${PROJECT_BINARY_DIR}/graphiteooo_${EXTENSION_PLATFORM}.oxt
+ COMMENT reinstall the extension for current user)
+
add_dependencies(copy_files graphiteooo)
add_dependencies(ooextension copy_files)
@@ -1,10 +1,11 @@
# GraphiteOptions strings
2.GraphiteOptions.HelpText=
-3.GraphiteOptions.Title=Graphite ဖောင့်ရွေးပိုင်ခွင့်များ
+3.GraphiteOptions.Title=Graphite ဖောင့်ရွေးပိုင်ခွင့်များ
4.GraphiteOptions.GraphiteFrameControl.HelpText=
5.GraphiteOptions.GraphiteFrameControl.Label=Graphite ဖောင့်ရွေးပိုင်ခွင့်များ
6.GraphiteOptions.EnableGraphiteCheckBox.HelpText=
-7.GraphiteOptions.EnableGraphiteCheckBox.Label=အသုံးပြုနိုင်သော Graphite ဖောင့်ခင်းပြခြင်း 8.GraphiteOptions.EnableGraphiteLabel.HelpText=
+7.GraphiteOptions.EnableGraphiteCheckBox.Label=အသုံးပြုနိုင်သော Graphite ဖောင့်ခင်းပြခြင်း
+8.GraphiteOptions.EnableGraphiteLabel.HelpText=
9.GraphiteOptions.EnableGraphiteLabel.Label=Graphite သည် ရှုပ်ထွေးသောရေးသားနည်းများနှင့် အက္ခရာပေါင်းစည်းသင်္ကေတများခင်းပြခြင်းအတွက် Opentype ကိုသွယ်ဝိုက်သုံးသောဖောင့်နည်းပညာတစ်ခုဖြစ်သည်။ ၎င်းကို နိုင်ငံတကာသုံး SIL ဖောင့်များတွင် အဓိကတွေ့ရှိနိုင်သည်။\n OpenOffice ကိုပြန်စပြီးနောက်မှသာလျှင် အသုံးပြုနိုင်သော (သို့) အသုံးမပြုနိုင်သော Graphite ကိုပြောင်းနိုင်လိမ့်မည်။ တက်ဘ်ဘားရှိ အမြန်စတင်မှုနှင့် Openoffice ဝင်းဒိုးမျာအားလုံးပါ ပိတ်ရန် မမေ့ပါနှင့်။
10.GraphiteOptions.FrameInstalledGraphiteFonts.HelpText=
11.GraphiteOptions.FrameInstalledGraphiteFonts.Label=Graphite ဖောင့်များထည့်သွင်းခဲ့သည်။
@@ -15,6 +16,6 @@
26.GraphiteOptions.CacheFrameControl.HelpText=
27.GraphiteOptions.CacheFrameControl.Label=Graphite မြန်နှုန်းမြင့်သိုလှောင်မှု
28.GraphiteOptions.CacheMinLabel.HelpText=
-29.GraphiteOptions.CacheMinLabel.Labe=အငယ်
+29.GraphiteOptions.CacheMinLabel.Label=အငယ်
32.GraphiteOptions.CacheMaxLabel.HelpText=
33.GraphiteOptions.CacheMaxLabel.Label=အကြီး
@@ -8,6 +8,7 @@
<value/>
<value xml:lang="en">Graphite Features...</value>
<value xml:lang="hu">Graphite tulajdonságok...</value>
+ <value xml:lang="my-MM">Graphite အင်္ဂါများ...</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
@@ -37,6 +38,7 @@
<value/>
<value xml:lang="en">Graphite Options</value>
<value xml:lang="hu">Graphite beállítások</value>
+ <value xml:lang="my-MM">Graphite ဖောင့်ရွေးပိုင်ခွင့်များ</value>
</prop>
</node>
</node>
@@ -14,6 +14,7 @@
<prop oor:name="Label">
<value xml:lang="en-US">Graphite Fonts</value>
<value xml:lang="hu">Graphite beállítások</value>
+ <value xml:lang="my">Graphite ဖောင့်</value>
</prop>
<prop oor:name="OptionsPage">
<value>%origin%/../../../../../dialogs/GraphiteOptions.xdl</value>
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="GraphiteOptions" oor:package="org.sil.graphite">
+ <node oor:name="Leaves">
+ <prop oor:name="graphiteEnabled">
+ <value>true</value>
+ </prop>
+ <prop oor:name="cacheSize">
+ <value>2047</value>
+ </prop>
+ </node>
+</oor:component-data>
+
@@ -98,11 +98,6 @@ ::sal_Bool SAL_CALL org::sil::graphite::FeatureDialogEventHandler::callHandlerMe
MethodName.convertToString(&aMethodName, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS);
logMsg("FeatureDialogEventHandler callHandlerMethod(%s)\n", aMethodName.getStr());
#endif
- // TODO: Exchange the default return implementation for "callHandlerMethod" !!!
- // Exchange the default return implementation.
- // NOTE: Default initialized polymorphic structs can cause problems because of
- // missing default initialization of primitive types of some C++ compilers or
- // different Any initialization in Java and C++ polymorphic structs.
return sal_False;
}
@@ -233,68 +228,97 @@ void org::sil::graphite::FeatureDialogEventHandler::addFontFeatures(
gr::lgid en_US(0x0409);
std::pair<gr::FeatureIterator, gr::FeatureIterator>iFeats = grFont->getFeatures();
std::pair<gr::FeatLabelLangIterator, gr::FeatLabelLangIterator > iFeatLangs = grFont->getFeatureLabelLanguages();
- gr::lgid lang = en_US;
+ gr::lgid lang = m_locale2Lang.getMsId(m_config.locale().Language, m_config.locale().Country, m_config.locale().Variant);
gr::FeatureIterator iFeat = iFeats.first;
#ifdef GROOO_DEBUG
logMsg("Loaded font with %d features\n", iFeats.second - iFeats.first);
#endif
while (iFeat != iFeats.second)
{
gr::utf16 featLabel[128];
- bool hasLabel = grFont->getFeatureLabel(iFeat, en_US, featLabel);
- // if we don't have English, randomly pick the first language for now
- if (!hasLabel && (iFeatLangs.first != iFeatLangs.second))
+ featLabel[0] = 0;
+ bool hasLabel = grFont->getFeatureLabel(iFeat, lang, featLabel);
+ if (!hasLabel)
{
- hasLabel = grFont->getFeatureLabel(iFeat, *(iFeatLangs.first), featLabel);
- lang = *(iFeatLangs.first);
+ // look for an entry with same language, but a different country
+ gr::FeatLabelLangIterator iFeatLang = iFeatLangs.first;
+ while (iFeatLang != iFeatLangs.second)
+ {
+ const IsoLangEntry * entry = m_locale2Lang.findEntryById(*iFeatLang);
+ if (entry && m_config.locale().Language.compareToAscii(entry->maLangStr) == 0)
+ {
+ lang = *iFeatLang;
+ hasLabel = grFont->getFeatureLabel(iFeat, lang, featLabel);
+ break;
+ }
+ ++iFeatLang;
+ }
+ // try English
+ if (!hasLabel && grFont->getFeatureLabel(iFeat, en_US, featLabel))
+ {
+ hasLabel = true;
+ lang = en_US;
+ }
+ // if we don't have English, randomly pick the first language
+ if (!hasLabel && (iFeatLangs.first != iFeatLangs.second))
+ {
+ hasLabel = grFont->getFeatureLabel(iFeat, *(iFeatLangs.first), featLabel);
+ lang = *(iFeatLangs.first);
#ifdef GROOO_DEBUG
- logMsg("Feature label for en_US not found using lang %x\n", lang);
+ logMsg("Feature label not found for requested language using %x\n", lang);
#endif
+ }
}
::rtl::OUString featName(reinterpret_cast<sal_Unicode*>(featLabel));
- if (hasLabel)
+ if (!hasLabel)
{
- css::uno::Reference<css::awt::tree::XMutableTreeNode> featNode = xMutableDataModel.get()->createNode(css::uno::Any(featName), sal_False);
- featNode.get()->setDataValue(css::uno::Any(static_cast<sal_uInt32>(*iFeat)));
- css::uno::Reference<css::awt::tree::XTreeNode> xFeatTreeNode(featNode, css::uno::UNO_QUERY);
- fontNode.get()->appendChild(featNode);
- m_xTree.get()->makeNodeVisible(xFeatTreeNode);
-
- std::pair<gr::FeatureSettingIterator, gr::FeatureSettingIterator > iSettings = grFont->getFeatureSettings(iFeat);
- gr::FeatureSettingIterator iSetting = iSettings.first;
- gr::FeatureSettingIterator defaultValue = grFont->getDefaultFeatureValue(iFeat);
- sal_Int32 value = *defaultValue;
- if (m_featureSettings[fontScript].find(*iFeat) != m_featureSettings[fontScript].end())
- value = m_featureSettings[fontScript][*iFeat];
+ featName = grInfo.featId2OUString(*iFeat);
+ }
+ css::uno::Reference<css::awt::tree::XMutableTreeNode> featNode = xMutableDataModel.get()->createNode(css::uno::Any(featName), sal_False);
+ featNode.get()->setDataValue(css::uno::Any(static_cast<sal_uInt32>(*iFeat)));
+ css::uno::Reference<css::awt::tree::XTreeNode> xFeatTreeNode(featNode, css::uno::UNO_QUERY);
+ fontNode.get()->appendChild(featNode);
+ m_xTree.get()->makeNodeVisible(xFeatTreeNode);
+
+ std::pair<gr::FeatureSettingIterator, gr::FeatureSettingIterator > iSettings = grFont->getFeatureSettings(iFeat);
+ gr::FeatureSettingIterator iSetting = iSettings.first;
+ gr::FeatureSettingIterator defaultValue = grFont->getDefaultFeatureValue(iFeat);
+ sal_Int32 value = *defaultValue;
+ if (m_featureSettings[fontScript].find(*iFeat) != m_featureSettings[fontScript].end())
+ value = m_featureSettings[fontScript][*iFeat];
#ifdef GROOO_DEBUG
- logMsg("Feature %d has %d settings\n", iFeat - iFeats.first, iSettings.second - iSettings.first);
+ logMsg("Feature %d has %d settings\n", iFeat - iFeats.first, iSettings.second - iSettings.first);
#endif
- while (iSetting != iSettings.second)
+ while (iSetting != iSettings.second)
+ {
+ featLabel[0] = 0;
+ hasLabel = grFont->getFeatureSettingLabel(iSetting, lang, featLabel);
+ assert(sizeof(gr::utf16) == sizeof(sal_Unicode));
+ ::rtl::OUString settingName(reinterpret_cast<sal_Unicode*>(featLabel));
+ if (!hasLabel)
{
- hasLabel = grFont->getFeatureSettingLabel(iSetting, lang, featLabel);
- assert(sizeof(gr::utf16) == sizeof(sal_Unicode));
- ::rtl::OUString settingName(reinterpret_cast<sal_Unicode*>(featLabel));
- if (*iSetting == *defaultValue)
- settingName += defaultLabel;
- css::uno::Reference<css::awt::tree::XMutableTreeNode> settingNode = xMutableDataModel.get()->createNode(css::uno::Any(settingName), sal_False);
- settingNode.get()->setDataValue(css::uno::Any(static_cast<sal_Int32>(*iSetting)));
- featNode.get()->appendChild(settingNode);
- if (*iSetting == value)
- {
- settingNode.get()->setNodeGraphicURL(m_extensionBase + ENABLED_ICON);
- // make non-default settings visible
- if (value != *defaultValue)
- {
- css::uno::Reference<css::awt::tree::XTreeNode> xFeatSettingTreeNode(settingNode, css::uno::UNO_QUERY);
- m_xTree.get()->makeNodeVisible(xFeatSettingTreeNode);
- }
- }
- else
+ settingName = grInfo.featSetting2OUString(*iSetting);
+ }
+ if (*iSetting == *defaultValue)
+ settingName += defaultLabel;
+ css::uno::Reference<css::awt::tree::XMutableTreeNode> settingNode = xMutableDataModel.get()->createNode(css::uno::Any(settingName), sal_False);
+ settingNode.get()->setDataValue(css::uno::Any(static_cast<sal_Int32>(*iSetting)));
+ featNode.get()->appendChild(settingNode);
+ if (*iSetting == value)
+ {
+ settingNode.get()->setNodeGraphicURL(m_extensionBase + ENABLED_ICON);
+ // make non-default settings visible
+ if (value != *defaultValue)
{
- settingNode.get()->setNodeGraphicURL(m_extensionBase + DISABLED_ICON);
+ css::uno::Reference<css::awt::tree::XTreeNode> xFeatSettingTreeNode(settingNode, css::uno::UNO_QUERY);
+ m_xTree.get()->makeNodeVisible(xFeatSettingTreeNode);
}
- ++iSetting;
}
+ else
+ {
+ settingNode.get()->setNodeGraphicURL(m_extensionBase + DISABLED_ICON);
+ }
+ ++iSetting;
}
++iFeat;
}
@@ -48,6 +48,7 @@
#include "com/sun/star/frame/XController.hpp"
#include "GraphiteConfiguration.hxx"
+#include "locale2lcid.hxx"
namespace gr { class Font; }
@@ -143,6 +144,7 @@ private:
css::uno::Reference< css::beans::XPropertySet> m_xTextProperties;
css::uno::Reference< css::beans::XPropertySet> m_xStyleTextProperties;
GraphiteConfiguration m_config;
+ Locale2Lang m_locale2Lang;
css::uno::Reference< css::resource::XStringResourceResolver> m_xResource;
::rtl::OUString m_extensionBase;
std::map<sal_uInt32, sal_Int32> m_featureSettings[NUM_SCRIPTS];
Oops, something went wrong.

0 comments on commit 0e0ec80

Please sign in to comment.