FRED™
3.0
FRED™: Framework for Rapid and Easy Development
|
Translations component. More...
Public Member Functions | |
langs () | |
Available languages. More... | |
getStr ($id, $default=false) | |
Basic string getter. More... | |
escape ($tags) | |
Escape tag values (convert special characters to HTML entities). More... | |
str ($str, $tags=null) | |
Translate a string. More... | |
id ($id, $tags=null, $default=false) | |
Translate a string by ID. More... | |
fragment ($id) | |
__call ($func_name, $params) | |
__invoke ($str, $tags=null) | |
Public Member Functions inherited from Component | |
__construct ($fred, $config=null) | |
__destruct () | |
clientConfig () | |
Public configuration. More... | |
config ($key, $default=null) | |
Retrieve a config value. More... | |
ping () | |
Ping function. More... | |
filemtime ($filename) | |
Filemtime with session cache. More... | |
component ($name) | |
Get a component (local or default). More... | |
components (... $names) | |
Get multiple components in an array. More... | |
Public Member Functions inherited from Thing | |
propertyExists ($property) | |
Check if a property exists (public or published). More... | |
constants ($prefix=null) | |
Return all constants. More... | |
get ($key) | |
Get one or more properties. More... | |
set ($key, $value=null) | |
Set one or more properties. More... | |
__get ($key) | |
__set ($key, $value) | |
Data Fields | |
const | TYPE_TAG = '+' |
Add a tag to to the tags: [+tag|value]. More... | |
const | TYPE_OPTIONAL = '?' |
Optional sub-string (defaults to empty; no error): [?strId]. More... | |
const | TYPE_SUBSTR = '@' |
Points to a sub-string: [@strId]. More... | |
const | TYPE_TRUE = '%' |
Show section when tag value is true: {[tag]show when tag is not empty}. More... | |
const | TYPE_FALSE = '!' |
Show section when tag value is false: {[!tag]show when tag is empty}. More... | |
const | TYPE_COUNT = '#' |
Insert number of items in array: Array has [#arrayTag] items. More... | |
const | TYPE_SUM = '=' |
Sum of an array column: [=array|column|formatting]. More... | |
const | TYPE_ARRAY = '*' |
Repeat section for each item (item aded to tags, including k = key, v = value - when record is. More... | |
const | TYPE_DECODE = ':' |
Decode a value: [:intTag|1:foo|2:bar|default]. Set the value to '?' for a random selection. More... | |
const | TYPE_JSON = '$' |
Insert a JSON encoded value. More... | |
const | TYPE_RAW = '~' |
Insert value without inserting a conditional tag: [[~intTag],number]. More... | |
const | MACRO_ESCAPE = 'escape' |
Escape the text between these tags (pre processing). More... | |
const | MACRO_SPACE = 'space' |
Remove white-space between tags. More... | |
const | MACRO_REPLACE = 'replace' |
Replace the text in attribute 'from' (regex) to 'to'. More... | |
const | MACRO_UNITS = 'units' |
Split the value of the tag name into units, so it can be used as an array (units in desired. More... | |
const | MACRO_CONST = 'const' |
Replace the text with the value of the constant between the tags (pre processing). More... | |
const | MACRO_CACHE = 'cache' |
Cache the (processed) text (set the 'ttl' tag to use the main cache; use the 'key'. More... | |
const | MACRO_FRAGMENT = 'fragment' |
Replace the tag with a placeholder and replace it with the fragment later on (with. More... | |
const | MACRO_ROUTE = 'route' |
Create a (reverse) route for the controller name between the tags (attributes are params). More... | |
const | MACRO_LOCATION = 'location' |
Rewrite the location between the tags (pre processing). More... | |
const | MACRO_IMAGE = 'image' |
Generate an image tag for the image between the tags (the content is cached, set the 'ttl'. More... | |
const | MACRO_URL = 'url' |
Load external content from the address between the tags (the content is cached, set the 'ttl'. More... | |
const | MACRO_RIGHT = 'right' |
const | EVENT_FORMAT = 'trans:format:' |
$namespace = 'trans' | |
$maxNested = 10 | |
Maximum number of times a sub-string may be nested. More... | |
$logPrio = Log::INFO | |
Prio for translation related errors (invalid tags, format, etc). More... | |
$imageTtl = 86400 | |
Default cache TTL for image tag generation. More... | |
$imageKeyPrefix = 'trans-image-' | |
$urlTtl = 86400 | |
Default cache TTL for external content. More... | |
$urlKeyPrefix = 'trans-url-' | |
$cacheKeyPrefix = 'trans-cache-' | |
Data Fields inherited from Component | |
$filemtimeTtl = 0 | |
Data Fields inherited from Thing | |
const | HIDDEN = 0 |
Property is hidden. More... | |
const | READABLE = 1 |
Property is readable. More... | |
const | WRITEABLE = 2 |
Property is writeable. More... | |
const | READWRITE = 3 |
Property is readable and writeable. More... | |
Protected Member Functions | |
init () | |
error ($message, $file=null, $line_no=null, $context=null) | |
getStrs ($lang_id) | |
Get all strings. More... | |
macro ($str, $type, &$tags, $callback) | |
preProcess ($str, &$tags) | |
postProcess ($str, &$tags) | |
value ($tag, $params, &$tags) | |
evaluate ($expr, $tag, &$tags) | |
formatSubstr ($value, $start, $length=null) | |
formatReplace ($value, $search, $replace) | |
formatRegex ($value, $pattern, $replace) | |
format ($tag, $value, $params, &$tags) | |
Format a value. More... | |
replace ($str, $full, $type, $tag, $operator,$params, $value, &$tags, &$strs) | |
Replace a tag with its value. More... | |
brush ($str) | |
Elaborate conditional parts. More... | |
trans ($str, $tags=null) | |
Translate a string. More... | |
getRegex () | |
setTags ($value) | |
getTypes () | |
_get ($key) | |
Protected Member Functions inherited from Component | |
init () | |
done () | |
getSession () | |
Protected Member Functions inherited from Thing | |
publish ($property, $visibility=self::READABLE) | |
Publish a property (or hide it again). More... | |
configure ($config) | |
Configure the object. More... | |
_get ($key) | |
Default getter if no specific setter is defined, and the property is also not published (readable). More... | |
_set ($key, $value) | |
Default setter if no specific setter is defined, and the property is also not published (writeable). More... | |
Protected Attributes | |
$_langId = null | |
$_filename = null | |
Filename for the translations (asterisk will be replace by the langId). More... | |
$_prefix = null | |
$_strs = [] | |
$_tags = [] | |
Default tags to use with every translation. More... | |
$_escape = [] | |
$_unescape = [] | |
$_cache = [] | |
$_types = null | |
$_regex = null | |
Protected Attributes inherited from Component | |
$_fred = null | |
$_config = null | |
$_name = null | |
$_components = [] | |
Local components (key = component name, value = component). More... | |
$_session = null | |
Protected Attributes inherited from Thing | |
$_published = [] | |
Published properties (key = name of property, value = visibility). More... | |
|
protected |
|
protected |
escape | ( | $tags | ) |
|
protected |
getStr | ( | $id, | |
$default = false |
|||
) |
|
protected |
id | ( | $id, | |
$tags = null , |
|||
$default = false |
|||
) |
langs | ( | ) |
|
protected |
Replace a tag with its value.
string | $str | String to replace tag in. |
string | $full | Full match for the tag (including brackets). |
string | $type | Type of tag (see TYPE_* constants). |
string | $tag | Name of the tag. |
string | $operator | Operator for the tag (e.g. '=='). |
string | $params | Extra parameters in the tag. |
mixed | $value | Value for the tag. |
array | $tags | All available tags (values). |
array | $strs | Loaded sub-strings. |
str | ( | $str, | |
$tags = null |
|||
) |
|
protected |
Translate a string.
string | $str | Basic string with tags. |
array | $tags | Tags to use when translating the string. Values are automaticle escaped, except when the key starts with a '!'. For keys starting with a '@' the value is used as a callback function (only called when the tag is present in the string; use '@!' prefix for callback values that should not be escaped). |
|
protected |
|
protected |
$imageTtl = 86400 |
$logPrio = Log::INFO |
$maxNested = 10 |
const MACRO_CACHE = 'cache' |
const MACRO_CONST = 'const' |
const MACRO_ESCAPE = 'escape' |
const MACRO_FRAGMENT = 'fragment' |
const MACRO_IMAGE = 'image' |
const MACRO_LOCATION = 'location' |
const MACRO_REPLACE = 'replace' |
const MACRO_ROUTE = 'route' |
const MACRO_SPACE = 'space' |
const MACRO_UNITS = 'units' |
const MACRO_URL = 'url' |
const TYPE_ARRAY = '*' |
const TYPE_COUNT = '#' |
const TYPE_DECODE = ':' |
const TYPE_FALSE = '!' |
const TYPE_OPTIONAL = '?' |
const TYPE_RAW = '~' |
const TYPE_SUM = '=' |
const TYPE_TAG = '+' |
const TYPE_TRUE = '%' |