BomAle Posted May 28, 2016 Posted May 28, 2016 When we try to translate the language pack in default words you can not know if there are spaces at the beginning and end of the string.@EnzoC @RPG-support @Maxxius @Carlos S. @Hobbe @Teascu Dorin @Foster .... This is where I thought to modify the table output and allow to highlight spaces. find on file \applications\core\modules\admin\languages\languages.php: 'word_custom' => function( $val, $row ) { return \IPS\Theme::i()->getTemplate( 'customization' )->langString( $val, $row['word_key'], $row['lang_id'], $row['word_js'] ); }, add before it 'word_default' => function( $val, $row ) { $val = mb_substr($val, 0, 1) === ' ' ? substr_replace($val, '<span style="background-color:#F00;"> </span>', 0, -mb_strlen($val)+1) : $val; $val = (mb_strlen($val) > 1 AND mb_strpos($val, ' ', mb_strlen($val)-1) !== FALSE) ? substr_replace($val,'<span style="background-color:#F00;"> </span>', -1) : $val; return $val; }, Mine is a manual change but wanted to incite the staff to integrate as soon as the functionality.... If this is not integrated soon i release a plugin.
BomAle Posted May 28, 2016 Author Posted May 28, 2016 'lang_filter_space' => 'CHAR_LENGTH(word_default) != CHAR_LENGTH(TRIM(word_default))'
BomAle Posted May 30, 2016 Author Posted May 30, 2016 'word_default' => function( $val, $row ) { $val = htmlspecialchars( $val, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ); $val = mb_substr($val, 0, 1) === ' ' ? substr_replace($val, '<span style="background-color:#F00;"> </span>', 0, -mb_strlen($val)+1) : $val; $val = (mb_strlen($val) > 1 AND mb_strpos($val, ' ', mb_strlen($val)-1) !== FALSE) ? substr_replace($val,'<span style="background-color:#F00;"> </span>', -1) : $val; return $val; }, This not translate html tags on $val.
BomAle Posted May 31, 2016 Author Posted May 31, 2016 $table->advancedSearch = array( 'word_key' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT, 'word_default' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT, 'word_custom' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT, 'word_app' => array( \IPS\Helpers\Table\SEARCH_NODE, array( 'class'=> 'IPS\Application', 'zeroVal' => 'any', 'multiple' => TRUE )), 'word_plugin' => array( \IPS\Helpers\Table\SEARCH_NODE, array( 'class'=> 'IPS\Plugin', 'zeroVal' => 'any', 'multiple' => TRUE )), ); $table->filters = array( 'lang_filter_translated' => 'word_custom IS NOT NULL', 'lang_filter_untranslated' => 'word_custom IS NULL', 'lang_filter_out_of_date' => 'word_custom IS NOT NULL AND word_custom_version<word_default_version', 'lang_filter_space' => 'CHAR_LENGTH(word_default) != CHAR_LENGTH(TRIM(word_default)) OR CHAR_LENGTH(word_custom) != CHAR_LENGTH(TRIM(word_custom))', 'lang_filter_equal' => 'TRIM(word_default) = TRIM(word_custom)', );
Recommended Posts
Archived
This topic is now archived and is closed to further replies.