File tree Expand file tree Collapse file tree
locales/zh_CN/LC_MESSAGES Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ """
4+ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
5+ See the file 'LICENSE' for copying permission
6+
7+ Internationalization (i18n) support using GNU gettext.
8+ """
9+
10+ import gettext
11+ import os
12+ import sys
13+
14+ _LOCALE_DIR = os .path .join (os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))), "locales" )
15+
16+ _DOMAIN = "sqlmap"
17+
18+ _translation = None
19+
20+ def init (language = None ):
21+ """
22+ Initialize gettext translation.
23+
24+ If no language is specified, try to detect from system locale.
25+ """
26+ global _translation
27+
28+ if language is None :
29+ import locale
30+ try :
31+ language , _ = locale .getdefaultlocale ()
32+ except Exception :
33+ language = os .environ .get ("LANG" , "en_US.UTF-8" )
34+
35+ if language :
36+ language = language .split ("." )[0 ] # e.g., "zh_CN.UTF-8" -> "zh_CN"
37+
38+ try :
39+ if language and language != "en_US" :
40+ _translation = gettext .translation (
41+ _DOMAIN ,
42+ localedir = _LOCALE_DIR ,
43+ languages = [language ],
44+ fallback = True
45+ )
46+ else :
47+ _translation = gettext .NullTranslations ()
48+ except Exception :
49+ _translation = gettext .NullTranslations ()
50+
51+ # Install the _() function into builtins so it's available everywhere
52+ if isinstance (_translation , gettext .NullTranslations ):
53+ import builtins
54+ builtins .__dict__ ["_" ] = lambda msg : msg
55+ else :
56+ _translation .install ()
57+
58+
59+ def _ (message ):
60+ """
61+ Translate a message.
62+ """
63+ global _translation
64+ if _translation is None :
65+ init ()
66+ return _translation .gettext (message ) if _translation else message
You can’t perform that action at this time.
0 commit comments