23 return [
'.strings' ];
32 $lines = explode(
"\n", $data );
33 $authors = $messages = [];
34 $linecontinuation =
false;
37 foreach ( $lines as $line ) {
38 $line = trim( $line );
39 if ( $linecontinuation ) {
40 if ( strpos( $line,
'*/' ) !==
false ) {
41 $linecontinuation =
false;
48 if ( substr( $line, 0, 2 ) ===
'//' ) {
51 $ok = preg_match(
'~//\s*Author:\s*(.*)~', $line, $match );
53 $authors[] = $match[1];
58 if ( substr( $line, 0, 2 ) ===
'/*' ) {
59 if ( strpos( $line,
'*/', 2 ) ===
false ) {
60 $linecontinuation =
true;
65 list( $key, $value ) = static::readRow( $line );
66 $messages[$key] = $value;
70 $messages = $this->group->getMangler()->mangleArray( $messages );
73 'AUTHORS' => $authors,
74 'MESSAGES' => $messages,
87 if ( preg_match(
'/^"((?:\\\"|[^"])*)"\s*=\s*"((?:\\\"|[^"])*)"\s*;\s*$/', $line, $match ) ) {
91 throw new MWException(
"Empty key in line $line" );
93 return [ $key, $value ];
95 throw new MWException(
"Unrecognized line format: $line" );
104 $header = $this->
doHeader( $collection );
105 $header .= $this->
doAuthors( $collection );
109 $mangler = $this->group->getMangler();
112 foreach ( $collection as $key => $m ) {
113 $value = $m->translation();
114 $value = str_replace( TRANSLATE_FUZZY,
'', $value );
116 if ( $value ===
'' ) {
121 if ( $m->hasTag(
'fuzzy' ) ) {
122 $output .=
"// Fuzzy\n";
125 $key = $mangler->unmangle( $key );
126 $output .= static::writeRow( $key, $value );
130 $data = $header . $output;
166 $str = addcslashes( $str,
'\\"' );
167 $str = str_replace(
"\n",
'\\n', $str );
180 return stripcslashes( $str );
188 if ( isset( $this->extra[
'header'] ) ) {
189 $output = $this->extra[
'header'];
193 $code = $collection->code;
194 $name = Utilities::getLanguageName( $code );
195 $native = Utilities::getLanguageName( $code, $code );
196 $output =
"// Messages for $name ($native)\n";
197 $output .=
"// Exported from $wgSitename\n";
210 $authors = $this->
filterAuthors( $authors, $collection->code );
212 foreach ( $authors as $author ) {
213 $output .=
"// Author: $author\n";
219 public static function getExtraSchema() {
AppleFFS class implements support for Apple .strings files.
static readRow( $line)
Parses non-empty strings file row to key and value.
doAuthors(MessageCollection $collection)
writeReal(MessageCollection $collection)
static writeRow( $key, $value)
Writes well-formed properties file row with key and value.
static escapeString( $str)
Escape Obj-C-style strings; use backslash-escapes etc.
static unescapeString( $str)
Unescape Obj-C-style strings; can include backslash-escapes.
supportsFuzzy()
Query the capabilities of this FFS.
static quoteString( $str)
Quote and escape Obj-C-style strings for .strings format.
getFileExtensions()
Return the commonly used file extensions for these formats.
doHeader(MessageCollection $collection)
filterAuthors(array $authors, $code)
Remove excluded authors.