Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • DBLocale
  • i18nTextCollector
  • Translatable

Interfaces

  • i18nEntityProvider
 1 <?php
 2 /**
 3  * Locale database field, mainly used in {@link Translatable} extension.
 4  * 
 5  * @todo Allowing showing locale values in different languages through Nice()
 6  * 
 7  * @package sapphire
 8  * @subpackage i18n
 9  */
10 class DBLocale extends Varchar {
11     
12     function __construct($name, $size = 16) {
13         parent::__construct($name, $size);
14     }
15 
16     /**
17      * See {@link getShortName()} and {@link getNativeName()}.
18      * 
19      * @param Boolean $showNative Show a localized version of the name instead, based on the 
20      *  field's locale value.
21      * @return String
22      */
23     function Nice($showNative=false) {
24         if ($showNative) {
25             return $this->getNativeName();
26         }
27         return $this->getShortName();
28     }
29     
30     function RFC1766() {
31         return i18n::convert_rfc1766($this->value);
32     }
33     
34     /**
35      * Resolves the locale to a common english-language
36      * name through {@link i18n::get_common_locales()}.
37      * 
38      * @return String
39      */
40     function getShortName() {
41         $common_names = i18n::get_common_locales();
42         return (isset($common_names[$this->value])) ? $common_names[$this->value] : false;
43     }
44     
45     /**
46      * @return String
47      */
48     function getLongName() {
49         return i18n::get_locale_name($this->value);
50     }
51 
52     /**
53      * Returns the localized name based on the field's value.
54      * Example: "de_DE" returns "Deutsch".
55      * 
56      * @return String
57      */
58     function getNativeName() {
59         $common_names = i18n::get_common_locales(true);
60         return (isset($common_names[$this->value])) ? $common_names[$this->value] : false;
61     }
62 }
63 ?>
64 
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0