]>
Commit | Line | Data |
---|---|---|
1a779f75 | 1 | |
2 | ||
3 | It seems there is no particularly nice way to do this - which | |
4 | sucks, presumably that's a result of a lack of code re-use in other | |
5 | places. [ taken from the Debian patch ] | |
6 | ||
7 | ||
8 | Index: xmlhelp/source/cxxhelp/provider/urlparameter.cxx | |
9 | =================================================================== | |
10 | RCS file: /cvs/util/xmlhelp/source/cxxhelp/provider/urlparameter.cxx,v | |
11 | retrieving revision 1.25 | |
12 | diff -u -p -u -r1.25 urlparameter.cxx | |
13 | --- xmlhelp/source/cxxhelp/provider/urlparameter.cxx 31 Oct 2001 13:08:14 -0000 1.25 | |
14 | +++ xmlhelp/source/cxxhelp/provider/urlparameter.cxx 17 Jan 2003 16:25:16 -0000 | |
15 | @@ -266,12 +266,32 @@ rtl::OUString URLParameter::get_title() | |
16 | ||
17 | return m_aTitle; | |
18 | } | |
19 | - | |
20 | + | |
21 | ||
22 | rtl::OUString URLParameter::get_language() | |
23 | { | |
24 | if( m_aLanguage.getLength() == 0 ) | |
25 | return m_aDefaultLanguage; | |
26 | + | |
27 | + // Check that we have the necessary files. The rationale is if | |
28 | + // help/<lang>/err.html exists then, we have localized help | |
29 | + // data, possibly not installed. Otherwise, we won't have | |
30 | + // localized help and we try to fallback to English. | |
31 | + rtl::OUString fileURL = | |
32 | + m_pDatabases->getInstallPathAsURL() | |
33 | + + m_pDatabases->lang( m_aLanguage ) | |
34 | + + rtl::OUString::createFromAscii( "/err.html" ); | |
35 | + | |
36 | + osl::DirectoryItem aDirItem; | |
37 | + osl::File aFile( fileURL ); | |
38 | + osl::FileStatus aStatus( FileStatusMask_FileSize ); | |
39 | + | |
40 | + if( osl::FileBase::E_None != osl::DirectoryItem::get( fileURL,aDirItem ) || | |
41 | + osl::FileBase::E_None != aFile.open( OpenFlag_Read ) || | |
42 | + osl::FileBase::E_None != aDirItem.getFileStatus( aStatus ) ) | |
43 | + { | |
44 | + m_aLanguage = rtl::OUString::createFromAscii( "en-US" ); | |
45 | + } | |
46 | ||
47 | return m_aLanguage; | |
48 | } | |
49 | Index: xmlhelp/source/treeview/tvread.cxx | |
50 | =================================================================== | |
51 | RCS file: /cvs/util/xmlhelp/source/treeview/tvread.cxx,v | |
52 | retrieving revision 1.13 | |
53 | diff -u -p -u -r1.13 tvread.cxx | |
54 | --- xmlhelp/source/treeview/tvread.cxx 8 Nov 2001 16:42:46 -0000 1.13 | |
55 | +++ xmlhelp/source/treeview/tvread.cxx 17 Jan 2003 16:25:16 -0000 | |
56 | @@ -704,7 +704,27 @@ ConfigData TVChildTarget::init( const Re | |
57 | aDirItem ) ) | |
58 | ret = locale.copy( 0,idx ); | |
59 | ||
60 | - url = url + ret; | |
61 | + rtl::OUString test_url = url + ret; | |
62 | + { | |
63 | + // Check that we have the necessary files. The rationale is if | |
64 | + // help/<lang>/err.html exists then, we have localized help | |
65 | + // data, possibly not installed. Otherwise, we won't have | |
66 | + // localized help and we try to fallback to English. | |
67 | + rtl::OUString errfileURL = test_url + rtl::OUString::createFromAscii( "/err.html" ); | |
68 | + | |
69 | + osl::DirectoryItem aDirItem; | |
70 | + osl::File aFile( errfileURL ); | |
71 | + osl::FileStatus aStatus( FileStatusMask_FileSize ); | |
72 | + | |
73 | + if( osl::FileBase::E_None != osl::DirectoryItem::get( errfileURL,aDirItem ) || | |
74 | + osl::FileBase::E_None != aFile.open( OpenFlag_Read ) || | |
75 | + osl::FileBase::E_None != aDirItem.getFileStatus( aStatus ) ) | |
76 | + { | |
77 | + locale = rtl::OUString::createFromAscii( "en-US" ); | |
78 | + test_url = url + locale.copy( 0, 2 ); | |
79 | + } | |
80 | + } | |
81 | + url = test_url; | |
82 | ||
83 | // first of all, try do determine whether there are any *.tree files present | |
84 |