|
Server IP : 10.131.40.8 / Your IP : 216.73.216.15 Web Server : Apache System : Linux webd008.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : ludmqhh ( 137773) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/ludmqhh/www/hotel-forum/wp-content/plugins/loco-translate/src/cli/../gettext/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* Gettext source string. Does not contain translations.
*/
class Loco_gettext_String {
/**
* @var array
*/
private $raw;
/**
* @var string
*/
private $plural;
/**
* Loco_gettext_String constructor.
*
* @param string $msgid Mandatory source
* @param string $msgctxt Optional context
*/
public function __construct( $msgid, $msgctxt = '' ){
$this->raw = [
'source' => (string) $msgid,
'context' => (string) $msgctxt,
];
}
/**
* Get singular form as raw array data
* @internal
* @return string[]
*/
public function exportSingular(){
return $this->raw;
}
/**
* Get plural form as raw array data
* @internal
* @return string[]
*/
public function exportPlural(){
return [
'source' => $this->plural,
];
}
/**
* @param string $prop
* @param string|array $value
* @param string $glue
* @return void
*/
private function merge( $prop, $value, $glue ){
if( is_string($value) ){
$value = [$value];
}
else if( ! is_array($value) ){
throw new InvalidArgumentException('Expected Array or String');
}
if( array_key_exists($prop,$this->raw) ){
$value = array_merge( explode($glue,$this->raw[$prop]), $value );
}
$this->raw[$prop] = implode($glue,$value);
}
/**
* @param array|string $refs
* @return self
*/
public function addFileReferences( $refs ){
$this->merge('refs',$refs,' ');
return $this;
}
/**
* @param array|string $notes
* @return self
*/
public function addExtractedComment( $notes ){
$this->merge('notes',$notes,' ');
return $this;
}
/**
* @param string $msgid_plural
* @return self
*/
public function pluralize( $msgid_plural ){
$this->plural = (string) $msgid_plural;
return $this;
}
/**
* @return bool
*/
public function hasPlural(){
return is_string($this->plural) && '' !== $this->plural;
}
/*public function __toString(){
return json_encode( $this->raw );
}*/
}