1
# See bottom of file for license and copyright information
2
package Foswiki::Configure::Checkers::Site::Locale;
3
use base 'Foswiki::Configure::Checker';
15
if ( $Foswiki::cfg{UseLocale} ) {
16
eval "use locale;use POSIX";
18
$Foswiki::cfg{UseLocale} = 0;
19
return $this->WARN( 'Disabling locales. Error was: ' . $@ );
21
my $locale = $Foswiki::cfg{Site}{Locale};
22
POSIX::setlocale( &POSIX::LC_CTYPE, $locale );
23
my $currentLocale = POSIX::setlocale(&POSIX::LC_CTYPE);
24
if ( $currentLocale ne $locale ) {
25
$e .= $this->WARN(<<HERE);
26
Unable to set locale to '$locale'. The actual locale is '$currentLocale'
27
- please test your locale settings. This warning can be ignored if you are
28
not planning to use locales (e.g. your site uses English only) - or you can
29
set {Site}{Locale} to 'C', which should always work.
32
if ( $locale !~ /[a-z]/i && $Foswiki::cfg{UseLocale} ) {
33
$e = $this->WARN(<<HERE);
34
UseLocale set but {Site}{Locale} '$locale' has no alphabetic characters
39
# Set the default site charset
40
unless ( defined( $Foswiki::cfg{Site}{CharSet} ) ) {
41
$Foswiki::cfg{Site}{CharSet} = 'iso-8859-1';
44
# Check for unusable multi-byte encodings as site character set
45
# - anything that enables a single ASCII character such as '[' to be
46
# matched within a multi-byte character cannot be used for Foswiki.
47
# Refuse to work with character sets that allow Foswiki syntax
48
# to be recognised within multi-byte characters.
49
# FIXME: match other problematic multi-byte character sets
50
if ( $Foswiki::cfg{UseLocale}
51
&& $Foswiki::cfg{Site}{CharSet} =~
52
m/^(?:iso-?2022-?|hz-?|gb2312|gbk|gb18030|.*big5|.*shift_?jis|ms.kanji|johab|uhc)/i
58
Cannot use this multi-byte encoding ('$Foswiki::cfg{Site}{CharSet}') as site character
59
encoding. Please set a different character encoding in the {Site}{Locale}
71
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
73
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
74
# Foswiki Contributors are listed in the AUTHORS file in the root
75
# of this distribution. NOTE: Please extend that file, not this notice.
77
# Additional copyrights apply to some or all of the code in this
80
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
81
# TWiki Contributors are listed in the AUTHORS file in the root
82
# of this distribution. NOTE: Please extend that file, not this notice.
84
# This program is free software; you can redistribute it and/or
85
# modify it under the terms of the GNU General Public License
86
# as published by the Free Software Foundation; either version 2
87
# of the License, or (at your option) any later version. For
88
# more details read LICENSE in the root of this distribution.
90
# This program is distributed in the hope that it will be useful,
91
# but WITHOUT ANY WARRANTY; without even the implied warranty of
92
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
94
# As per the GPL, removal of this notice is prohibited.