]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Locale patch from Faidon:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 29 Jul 2006 21:04:31 +0000 (21:04 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 29 Jul 2006 21:04:31 +0000 (21:04 +0000)
  - Adds a locale setting to setup files.
  - Proper local time, if the locale configuration option is used.
  - Support for UTF-8 (or ISO-8859-X) filenames in SVN. Before this patch,
    commiting (or even rcs_updating) on repositories with UTF-8 filenames was
    impossible.

IkiWiki.pm
IkiWiki/Rcs/svn.pm
debian/changelog
doc/ikiwiki.setup
doc/patchqueue/locale_patch.mdwn [deleted file]

index 2b877a370d7f37a95147d9a7eb6bdd92ca3d3095..085953a17220fa50b44bf42892d7f0683f524d21 100644 (file)
@@ -49,9 +49,21 @@ sub defaultconfig () { #{{{
        adminemail => undef,
        plugin => [qw{mdwn inline htmlscrubber}],
        timeformat => '%c',
        adminemail => undef,
        plugin => [qw{mdwn inline htmlscrubber}],
        timeformat => '%c',
+       locale => undef,
 } #}}}
    
 sub checkconfig () { #{{{
 } #}}}
    
 sub checkconfig () { #{{{
+       # locale stuff; avoid LC_ALL since it overrides everything
+       if (defined $ENV{LC_ALL}) {
+               $ENV{LANG} = $ENV{LC_ALL};
+               delete $ENV{LC_ALL};
+       }
+       if (defined $config{locale}) {
+               eval q{use POSIX};
+               $ENV{LANG} = $config{locale}
+                       if POSIX::setlocale(&POSIX::LANG, $config{locale});
+       }
+
        if ($config{w3mmode}) {
                eval q{use Cwd q{abs_path}};
                $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
        if ($config{w3mmode}) {
                eval q{use Cwd q{abs_path}};
                $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
index b5f5fb445832d65e4115831fc885823ceb687a5d..f01735afe74c86d5c3279ec0bb1ea1beaa83152e 100644 (file)
@@ -4,11 +4,33 @@
 use warnings;
 use strict;
 use IkiWiki;
 use warnings;
 use strict;
 use IkiWiki;
+use POSIX qw(setlocale LC_CTYPE);
 
 package IkiWiki;
                
 my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
 
 
 package IkiWiki;
                
 my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
 
+# svn needs LC_CTYPE set to a UTF-8 locale, so try to find one. Any will do.
+sub find_lc_ctype() {
+       my $current = setlocale(LC_CTYPE());
+       return $current if $current =~ m/UTF-?8$/i;
+
+       # Make some obvious attempts to avoid calling `locale -a`
+       foreach my $locale ("$current.UTF-8", "en_US.UTF-8", "en_GB.UTF-8") {
+               return $locale if setlocale(LC_CTYPE(), $locale);
+       }
+
+       # Try to get all available locales and pick the first UTF-8 one found.
+       if (my @locale = grep(/UTF-?8$/i, `locale -a`)) {
+               chomp @locale;
+               return $locale[0] if setlocale(LC_CTYPE(), $locale[0]);
+       }
+
+       # fallback to the current locale
+       return $current;
+} # }}}
+$ENV{LC_CTYPE} = $ENV{LC_CTYPE} || find_lc_ctype();
+
 sub svn_info ($$) { #{{{
        my $field=shift;
        my $file=shift;
 sub svn_info ($$) { #{{{
        my $field=shift;
        my $file=shift;
index 6ee1e7b146d6f79af8628bc18b62fca1ebe6e75e..6c07212fe355d2c8bdae4d2b51601cf772d5ee92 100644 (file)
@@ -11,8 +11,14 @@ ikiwiki (1.13) UNRELEASED; urgency=low
     when upgrading to get the cleanup globally.
   * Polygen plugin from Enrico.
   * htmltidy plugin from Faidon.
     when upgrading to get the cleanup globally.
   * Polygen plugin from Enrico.
   * htmltidy plugin from Faidon.
-
- -- Joey Hess <joeyh@debian.org>  Sat, 29 Jul 2006 16:43:50 -0400
+  * Locale patch from Faidon:
+    - Adds a locale setting to setup files.
+    - Proper local time, if the locale configuration option is used.
+    - Support for UTF-8 (or ISO-8859-X) filenames in SVN. Before this patch,
+      commiting (or even rcs_updating) on repositories with UTF-8 filenames was
+      impossible.
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 29 Jul 2006 16:56:26 -0400
 
 ikiwiki (1.12) unstable; urgency=low
 
 
 ikiwiki (1.12) unstable; urgency=low
 
index 9310a455668a9b24d5710118302d6839c00a36b1..ca230f7b0431ec4f6b0061de7d11ce8e936a5f40 100644 (file)
@@ -72,6 +72,8 @@ use IkiWiki::Setup::Standard {
        #exclude => qr/\*.wav/,
        # Time format (for strftime)
        #timeformat => '%c',
        #exclude => qr/\*.wav/,
        # Time format (for strftime)
        #timeformat => '%c',
+       # Locale to use. Must be a UTF-8 locale.
+       #locale => 'en_US.UTF-8',
        
        # To add plugins, list them here.
        #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
        
        # To add plugins, list them here.
        #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
diff --git a/doc/patchqueue/locale_patch.mdwn b/doc/patchqueue/locale_patch.mdwn
deleted file mode 100644 (file)
index 78e82f9..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-This v2 patch is a different approach after Joey's comments and some though.
-
-It achieves:
-
-1. Proper local time, if the locale configuration option is used,
-2. Support for UTF-8 (or ISO-8859-X) filenames in SVN. Before this
-patch, commiting (or even rcs_updating) on repositories with UTF-8
-filenames was impossible.
-
-The svn backend sets `LC_CTYPE` to the following, in order of preference:
-* The current locale, if it contains utf8/UTF-8,
-* The current locale with the string ".UTF-8" appended to it,
-* `en_US.UTF-8`/`en_GB.UTF-8` -- a bit hacky, but they're _very_ common and
-  they can help avoiding a call to `locale -a`, which may not be available
-  in the current system,
-* The first UTF-8 locale it encounters from `locale -a`. Note that `LC_CTYPE`
-  is the same for every UTF-8 locale, so it doesn't matter which one will be used.
-
--- [[Faidon]]
-
-----
-       Index: IkiWiki/Rcs/svn.pm
-       ===================================================================
-       --- IkiWiki/Rcs/svn.pm  (revision 967)
-       +++ IkiWiki/Rcs/svn.pm  (working copy)
-       @@ -4,11 +4,35 @@
-        use warnings;
-        use strict;
-        use IkiWiki;
-       +use POSIX qw(setlocale LC_CTYPE);
-        
-        package IkiWiki;
-                       
-        my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
-        
-       +sub find_lc_ctype() {
-       +       my $current = setlocale(LC_CTYPE);
-       +
-       +       # Respect current locale if it's a UTF-8 one
-       +       return $current if $current =~ m/UTF-?8$/i;
-       +
-       +       # Make some obvious attempts to avoid calling `locale -a`
-       +       foreach my $locale ("$current.UTF-8", "en_US.UTF-8", "en_GB.UTF-8") {
-       +               return $locale if setlocale(LC_CTYPE, $locale);
-       +       }
-       +
-       +       # Try to get all available locales and pick the first UTF-8 one if found
-       +       if (my @locale = grep(/UTF-?8$/i, `locale -a`)) {
-       +               chomp @locale;
-       +               return $locale[0] if setlocale(LC_CTYPE, $locale[0]);
-       +       }
-       +
-       +       # fallback to the current locale
-       +       return $current;
-       +
-       +} # }}}
-       +$ENV{LC_CTYPE} = $ENV{LC_CTYPE} || find_lc_ctype();
-       +
-        sub svn_info ($$) { #{{{
-               my $field=shift;
-               my $file=shift;
-       Index: IkiWiki.pm
-       ===================================================================
-       --- IkiWiki.pm  (revision 967)
-       +++ IkiWiki.pm  (working copy)
-       @@ -49,9 +49,21 @@
-               adminemail => undef,
-               plugin => [qw{mdwn inline htmlscrubber}],
-               timeformat => '%c',
-       +       locale => undef,
-        } #}}}
-           
-        sub checkconfig () { #{{{
-       +       # locale stuff; avoid LC_ALL since it overrides everything
-       +       if (defined $ENV{LC_ALL}) {
-       +               $ENV{LANG} = $ENV{LC_ALL};
-       +               delete $ENV{LC_ALL};
-       +       }
-       +       if (defined $config{locale}) {
-       +               eval q{use POSIX};
-       +               $ENV{LANG} = $config{locale}
-       +                       if POSIX::setlocale(&POSIX::LANG, $config{locale});
-       +       }
-       +
-               if ($config{w3mmode}) {
-                       eval q{use Cwd q{abs_path}};
-                       $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
-       Index: doc/ikiwiki.setup
-       ===================================================================
-       --- doc/ikiwiki.setup   (revision 967)
-       +++ doc/ikiwiki.setup   (working copy)
-       @@ -72,6 +72,9 @@
-               #exclude => qr/\*.wav/,
-               # Time format (for strftime)
-               #timeformat => '%c',
-       +       # Locale to be used, useful for language customization of last-modified
-       +       # time. WARNING: Must be a UTF-8 locale!
-       +       #locale => 'en_US.UTF-8',
-               
-               # To add plugins, list them here.
-               #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
\ No newline at end of file