1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.Locale:
==========================================================================================================================================
|phoenix_title| **wx.Locale**
==========================================================================================================================================
:ref:`wx.Locale` class encapsulates all language-dependent settings and is a generalization of the C locale concept.
In wxWidgets this class manages current locale. It also initializes and activates :ref:`wx.Translations` object that manages message catalogs.
For a list of the supported languages, please see :ref:`wx.Language` enum values. These constants may be used to specify the language in :meth:`wx.Locale.Init` and are returned by :meth:`wx.Locale.GetSystemLanguage` .
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>Locale</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.Locale_inheritance.png" alt="Inheritance diagram of Locale" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Locale.html" title="wx.Locale" alt="" coords="4,5,85,35"/> </map>
</p>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.Locale.__init__` This is the default constructor and it does nothing to initialize the object: :meth:`~Locale.Init` must be used to do that.
:meth:`~wx.Locale.AddCatalog` Calls :meth:`wx.Translations.AddCatalog` .
:meth:`~wx.Locale.AddCatalogLookupPathPrefix` Calls :meth:`wx.FileTranslationsLoader.AddCatalogLookupPathPrefix` .
:meth:`~wx.Locale.AddLanguage` Adds custom, user-defined language to the database of known languages.
:meth:`~wx.Locale.FindLanguageInfo` This function may be used to find the language description structure for the given locale, specified either as a two letter ``ISO`` language code (for example, "pt"), a language code followed by the country code ("pt_BR") or a full, human readable, language description ("Portuguese-Brazil").
:meth:`~wx.Locale.GetCanonicalName` Returns the canonical form of current locale name.
:meth:`~wx.Locale.GetHeaderValue` Calls :meth:`wx.Translations.GetHeaderValue` .
:meth:`~wx.Locale.GetInfo` Get the values of the given locale-dependent datum.
:meth:`~wx.Locale.GetLanguage` Returns the :ref:`wx.Language` constant of current language.
:meth:`~wx.Locale.GetLanguageCanonicalName` Returns canonical name (see :meth:`~Locale.GetCanonicalName` ) of the given language or empty string if this language is unknown.
:meth:`~wx.Locale.GetLanguageInfo` Returns a pointer to :ref:`wx.LanguageInfo` structure containing information about the given language or ``None`` if this language is unknown.
:meth:`~wx.Locale.GetLanguageName` Returns English name of the given language or empty string if this language is unknown.
:meth:`~wx.Locale.GetLocale` Returns the locale name as passed to the constructor or :meth:`~Locale.Init` .
:meth:`~wx.Locale.GetName` Returns the current short name for the locale (as given to the constructor or the :meth:`~Locale.Init` function).
:meth:`~wx.Locale.GetString` Calls :ref:`wx.GetTranslation`.
:meth:`~wx.Locale.GetSysName` Returns current platform-specific locale name as passed to setlocale().
:meth:`~wx.Locale.GetSystemEncoding` Tries to detect the user's default font encoding.
:meth:`~wx.Locale.GetSystemEncodingName` Tries to detect the name of the user's default font encoding.
:meth:`~wx.Locale.GetSystemLanguage` Tries to detect the user's default locale setting.
:meth:`~wx.Locale.Init` Initializes the :ref:`wx.Locale` instance.
:meth:`~wx.Locale.IsAvailable` Check whether the operating system and/or C run time environment supports this locale.
:meth:`~wx.Locale.IsLoaded` Calls :meth:`wx.Translations.IsLoaded` .
:meth:`~wx.Locale.IsOk` Returns ``True`` if the locale could be set successfully.
:meth:`~wx.Locale.__bool__`
:meth:`~wx.Locale.__nonzero__`
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.Locale.CanonicalName` See :meth:`~wx.Locale.GetCanonicalName`
:attr:`~wx.Locale.Language` See :meth:`~wx.Locale.GetLanguage`
:attr:`~wx.Locale.Locale` See :meth:`~wx.Locale.GetLocale`
:attr:`~wx.Locale.Name` See :meth:`~wx.Locale.GetName`
:attr:`~wx.Locale.SysName` See :meth:`~wx.Locale.GetSysName`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.Locale(object)
**Possible constructors**::
Locale()
Locale(language, flags=LOCALE_LOAD_DEFAULT)
Locale(name, shortName=EmptyString, locale=EmptyString,
bLoadDefault=True)
Locale class encapsulates all language-dependent settings and is a
generalization of the C locale concept.
.. method:: __init__(self, *args, **kw)
|overload| Overloaded Implementations:
**~~~**
**__init__** `(self)`
This is the default constructor and it does nothing to initialize the object: :meth:`Init` must be used to do that.
**~~~**
**__init__** `(self, language, flags=LOCALE_LOAD_DEFAULT)`
See :meth:`Init` for parameters description.
:param `language`:
:type `language`: int
:param `flags`:
:type `flags`: int
**~~~**
**__init__** `(self, name, shortName=EmptyString, locale=EmptyString, bLoadDefault=True)`
See :meth:`Init` for parameters description.
The call of this function has several global side effects which you should understand: first of all, the application locale is changed - note that this will affect many of standard C library functions such as printf() or strftime(). Second, this :ref:`wx.Locale` object becomes the new current global locale for the application and so all subsequent calls to :ref:`wx.GetTranslation` will try to translate the messages using the message catalogs for this locale.
:param `name`:
:type `name`: string
:param `shortName`:
:type `shortName`: string
:param `locale`:
:type `locale`: string
:param `bLoadDefault`:
:type `bLoadDefault`: bool
**~~~**
.. method:: AddCatalog(self, *args, **kw)
Calls :meth:`wx.Translations.AddCatalog` .
|overload| Overloaded Implementations:
**~~~**
**AddCatalog** `(self, domain)`
:param `domain`:
:type `domain`: string
:rtype: `bool`
**~~~**
**AddCatalog** `(self, domain, msgIdLanguage)`
:param `domain`:
:type `domain`: string
:param `msgIdLanguage`:
:type `msgIdLanguage`: wx.Language
:rtype: `bool`
**~~~**
**AddCatalog** `(self, domain, msgIdLanguage, msgIdCharset)`
:param `domain`:
:type `domain`: string
:param `msgIdLanguage`:
:type `msgIdLanguage`: wx.Language
:param `msgIdCharset`:
:type `msgIdCharset`: string
:rtype: `bool`
**~~~**
.. staticmethod:: AddCatalogLookupPathPrefix(prefix)
Calls :meth:`wx.FileTranslationsLoader.AddCatalogLookupPathPrefix` .
:param `prefix`:
:type `prefix`: string
.. staticmethod:: AddLanguage(info)
Adds custom, user-defined language to the database of known languages.
This database is used in conjunction with the first form of :meth:`Init` .
:param `info`:
:type `info`: wx.LanguageInfo
.. staticmethod:: FindLanguageInfo(locale)
This function may be used to find the language description structure for the given locale, specified either as a two letter ``ISO`` language code (for example, "pt"), a language code followed by the country code ("pt_BR") or a full, human readable, language description ("Portuguese-Brazil").
Returns the information for the given language or ``None`` if this language is unknown. Note that even if the returned pointer is valid, the caller should `not` delete it.
:param `locale`:
:type `locale`: string
:rtype: :ref:`wx.LanguageInfo`
.. seealso:: :meth:`GetLanguageInfo`
.. method:: GetCanonicalName(self)
Returns the canonical form of current locale name.
Canonical form is the one that is used on ``UNIX`` systems: it is a two- or five-letter string in xx or xx_YY format, where xx is ``ISO`` 639 code of language and ``YY`` is ``ISO`` 3166 code of the country. Examples are "en", "en_GB", "en_US" or "fr_FR". This form is internally used when looking up message catalogs. Compare :meth:`GetSysName` .
:rtype: `string`
.. method:: GetHeaderValue(self, header, domain=EmptyString)
Calls :meth:`wx.Translations.GetHeaderValue` .
:param `header`:
:type `header`: string
:param `domain`:
:type `domain`: string
:rtype: `string`
.. staticmethod:: GetInfo(index, cat=LOCALE_CAT_DEFAULT)
Get the values of the given locale-dependent datum.
This function returns the value of the locale-specific option specified by the given `index`.
:param `index`: One of the elements of LocaleInfo enum.
:type `index`: wx.LocaleInfo
:param `cat`: The category to use with the given index or ``wx.LOCALE_CAT_DEFAULT`` if the index can only apply to a single category.
:type `cat`: wx.LocaleCategory
:rtype: `string`
:returns:
The option value or empty string if the function failed.
.. method:: GetLanguage(self)
Returns the :ref:`wx.Language` constant of current language.
Note that you can call this function only if you used the form of :meth:`Init` that takes :ref:`wx.Language` argument.
:rtype: `int`
.. staticmethod:: GetLanguageCanonicalName(lang)
Returns canonical name (see :meth:`GetCanonicalName` ) of the given language or empty string if this language is unknown.
See :meth:`GetLanguageInfo` for a remark about special meaning of ``LANGUAGE_DEFAULT`` .
:param `lang`:
:type `lang`: int
:rtype: `string`
.. versionadded:: 2.9.1
.. staticmethod:: GetLanguageInfo(lang)
Returns a pointer to :ref:`wx.LanguageInfo` structure containing information about the given language or ``None`` if this language is unknown.
Note that even if the returned pointer is valid, the caller should `not` delete it.
See :meth:`AddLanguage` for the :ref:`wx.LanguageInfo` description. As with :meth:`Init` , ``LANGUAGE_DEFAULT`` has the special meaning if passed as an argument to this function and in this case the result of :meth:`GetSystemLanguage` is used.
:param `lang`:
:type `lang`: int
:rtype: :ref:`wx.LanguageInfo`
.. staticmethod:: GetLanguageName(lang)
Returns English name of the given language or empty string if this language is unknown.
See :meth:`GetLanguageInfo` for a remark about special meaning of ``LANGUAGE_DEFAULT`` .
:param `lang`:
:type `lang`: int
:rtype: `string`
.. method:: GetLocale(self)
Returns the locale name as passed to the constructor or :meth:`Init` .
This is a full, human-readable name, e.g. "English" or "French".
:rtype: `string`
.. method:: GetName(self)
Returns the current short name for the locale (as given to the constructor or the :meth:`Init` function).
:rtype: `string`
.. method:: GetString(self, *args, **kw)
Calls :ref:`wx.GetTranslation`.
|overload| Overloaded Implementations:
**~~~**
**GetString** `(self, origString, domain=EmptyString)`
:param `origString`:
:type `origString`: string
:param `domain`:
:type `domain`: string
:rtype: `string`
**~~~**
**GetString** `(self, origString, origString2, n, domain=EmptyString)`
:param `origString`:
:type `origString`: string
:param `origString2`:
:type `origString2`: string
:param `n`:
:param `domain`:
:type `domain`: string
:rtype: `string`
**~~~**
.. method:: GetSysName(self)
Returns current platform-specific locale name as passed to setlocale().
Compare :meth:`GetCanonicalName` .
:rtype: `string`
.. staticmethod:: GetSystemEncoding()
Tries to detect the user's default font encoding.
Returns :ref:`wx.FontEncoding` value or ``FONTENCODING_SYSTEM`` if it couldn't be determined.
:rtype: :ref:`wx.FontEncoding`
.. staticmethod:: GetSystemEncodingName()
Tries to detect the name of the user's default font encoding.
This string isn't particularly useful for the application as its form is platform-dependent and so you should probably use :meth:`GetSystemEncoding` instead.
Returns a user-readable string value or an empty string if it couldn't be determined.
:rtype: `string`
.. staticmethod:: GetSystemLanguage()
Tries to detect the user's default locale setting.
Returns the :ref:`wx.Language` value or ``LANGUAGE_UNKNOWN`` if the language-guessing algorithm failed.
:rtype: `int`
.. note::
This function works with `locales` and returns the user's default locale. This may be, and usually is, the same as their preferred UI language, but it's not the same thing. Use Translation to obtain `language` information.
.. seealso:: :meth:`wx.Translations.GetBestTranslation` .
.. method:: Init(self, *args, **kw)
|overload| Overloaded Implementations:
**~~~**
**Init** `(self, language=LANGUAGE_DEFAULT, flags=LOCALE_LOAD_DEFAULT)`
Initializes the :ref:`wx.Locale` instance.
The call of this function has several global side effects which you should understand: first of all, the application locale is changed - note that this will affect many of standard C library functions such as printf() or strftime(). Second, this :ref:`wx.Locale` object becomes the new current global locale for the application and so all subsequent calls to :ref:`wx.GetTranslation` will try to translate the messages using the message catalogs for this locale.
:param `language`: :ref:`wx.Language` identifier of the locale. ``LANGUAGE_DEFAULT`` has special meaning :ref:`wx.Locale` will use system's default language (see :meth:`GetSystemLanguage` ).
:type `language`: int
:param `flags`: Combination of the following:
- ``LOCALE_LOAD_DEFAULT``: Load the message catalog for the given locale containing the translations of standard wxWidgets messages automatically.
- ``LOCALE_DONT_LOAD_DEFAULT``: Negation of ``LOCALE_LOAD_DEFAULT``.
:type `flags`: int
:rtype: `bool`
:returns:
``True`` on success or ``False`` if the given locale couldn't be set.
**~~~**
**Init** `(self, name, shortName=EmptyString, locale=EmptyString, bLoadDefault=True)`
:param `name`: The name of the locale. Only used in diagnostic messages.
:type `name`: string
:param `shortName`: The standard 2 letter locale abbreviation; it is used as the directory prefix when looking for the message catalog files.
:type `shortName`: string
:param `locale`: The parameter for the call to setlocale(). Note that it is platform-specific.
:type `locale`: string
:param `bLoadDefault`: May be set to ``False`` to prevent loading of the message catalog for the given locale containing the translations of standard wxWidgets messages. This parameter would be rarely used in normal circumstances.
:type `bLoadDefault`: bool
:rtype: `bool`
.. wxdeprecated::
This form is deprecated, use the other one unless you know what you are doing.
**~~~**
.. staticmethod:: IsAvailable(lang)
Check whether the operating system and/or C run time environment supports this locale.
For example in Windows 2000 and Windows XP, support for many locales is not installed by default. Returns ``True`` if the locale is supported.
The argument `lang` is the :ref:`wx.Language` identifier. To obtain this for a given a two letter ``ISO`` language code, use :meth:`FindLanguageInfo` to obtain its :ref:`wx.LanguageInfo` structure. See :meth:`AddLanguage` for the :ref:`wx.LanguageInfo` description.
:param `lang`:
:type `lang`: int
:rtype: `bool`
.. versionadded:: 2.7.1.
.. method:: IsLoaded(self, domain)
Calls :meth:`wx.Translations.IsLoaded` .
:param `domain`:
:type `domain`: string
:rtype: `bool`
.. method:: IsOk(self)
Returns ``True`` if the locale could be set successfully.
:rtype: `bool`
.. method:: __bool__(self)
:rtype: `int`
.. method:: __nonzero__(self)
:rtype: `int`
.. attribute:: CanonicalName
See :meth:`~wx.Locale.GetCanonicalName`
.. attribute:: Language
See :meth:`~wx.Locale.GetLanguage`
.. attribute:: Locale
See :meth:`~wx.Locale.GetLocale`
.. attribute:: Name
See :meth:`~wx.Locale.GetName`
.. attribute:: SysName
See :meth:`~wx.Locale.GetSysName`
|