The following patch tries to improve the situation with accents in LyX
1.4 (this will be applied to 1.5 too, but I care now about 1.4.2).

The current situation now is that, if my locale is fr_FR.UTF-8, LyX
will change it to fr_FR and hope this makes sense. On linux, it is
indeed equivalent to fr_FR.ISO-8859-15 and all is well.

However, on some systems this basic locale may not exist or use ASCII
encoding (like e' for é) (this happens on the Mac).

This patch acts as a stopgap by keeping any charset specifier that is
not *UTF*.

Therefore

fr_FR.UTF-8 --> fr_FR
fr_FR --> fr_FR
fr_FR.ISO-8859-1 --> fr_FR.ISO-8859-1

This should make the OUTPUT_CHARSET hack unneeded on LyX/Mac.

This is definitely not perfect, but is simple and should uniformly
improve the situation.

I'd welcome testing.

JMarc

Index: src/messages.C
===================================================================
--- src/messages.C	(revision 14042)
+++ src/messages.C	(working copy)
@@ -89,15 +89,19 @@ public:
 	Pimpl(string const & l)
 		: lang_(l)
 	{
-		if ( lang_.empty() ) {
+		if (lang_.empty()) {
 			char const * lc_msgs = setlocale(LC_MESSAGES, NULL);
 			lang_ = lc_msgs ? lc_msgs : "";
 		}
-		// strip off any encoding suffix, i.e., assume 8-bit po files
-		string::size_type i = lang_.find(".");
-		lang_ = lang_.substr(0, i);
+		// strip off any UTF encoding suffix, i.e., assume
+		// 8-bit po files
+		string::size_type const i = lang_.find('.');
+		if (i != string::npos 
+		    && (lang_.find("UTF", i) != string::npos 
+			|| lang_.find("utf", i) != string::npos)) 
+			lang_ = lang_.substr(0, i);
 		lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
-                                     << ": language(" << lang_ << ")" << std::endl;
+                                     << ": language = " << lang_ << std::endl;
 	}
 
 	~Pimpl() {}

Reply via email to