666: Add CLDR support #784
Conversation
A couple of notes on the current state of this:
|
Really happy to see this PR. Left a few comments on a few very minor issues spotted while taking a quick look |
/* | ||
* Get the CLDR Data. | ||
* | ||
* By defualt it is read from the plurals.json file in the current directory, you can download |
yoavf
Jul 10, 2017
Member
typo defualt
typo defualt
// Create a working locales object. | ||
$locales = new GP_Locales; | ||
|
||
// Run through the locales and see if we can find a mathcing CLDR locale. |
yoavf
Jul 10, 2017
Member
Typo in mathcing
Typo in mathcing
@@ -24,11 +27,22 @@ function test_export() { | |||
$entries_for_export = array(); | |||
|
|||
foreach( $this->entries as $sample ) { | |||
list( $context, $original, $translation ) = $sample; | |||
list( $context, $original, $translation, $comment ) = $sample; |
yoavf
Jul 10, 2017
Member
Is the addition of the comment intentional in this patch?
Is the addition of the comment intentional in this patch?
toolstack
Jul 10, 2017
Author
Contributor
Yes, but only because it fixes an existing bug in the test case.
Yes, but only because it fixes an existing bug in the test case.
* | ||
* @return string HTML markup for a select element. | ||
*/ | ||
function gp_plurals_dropdown( $name_and_id, $selected_plural_type = null, $attrs = array() ) { |
ocean90
Oct 3, 2017
Member
Let's name this gp_plural_types_dropdown()
.
Let's name this gp_plural_types_dropdown()
.
toolstack
Oct 3, 2017
Author
Contributor
👍
@@ -12,6 +12,9 @@ | |||
<dt><label for="project[description]"><?php _e( 'Description', 'glotpress' ); ?></label> <span class="ternary"><?php _e( 'can include HTML', 'glotpress' ); ?></span></dt> | |||
<dd><textarea name="project[description]" rows="4" cols="40" id="project[description]"><?php echo esc_html( $project->description ); ?></textarea></dd> | |||
|
|||
<dt><label for="project[plurals_type]"><?php _e( 'Plurals Type', 'glotpress' ); ?></label></dt> | |||
<dd><?php echo gp_plurals_dropdown( 'project[plurals_type]', $project->plurals_type, array() ); // WPCS: XSS ok. ?></dd> |
ocean90
Oct 3, 2017
Member
gp_plurals_dropdown()
should be added to customAutoEscapedFunctions
in phpcs.xml.
gp_plurals_dropdown()
should be added to customAutoEscapedFunctions
in phpcs.xml.
toolstack
Oct 3, 2017
Author
Contributor
👍
} // End foreach(). | ||
|
||
// Add some space between locales for easier reading. | ||
echo "\n"; // WPCS: XSS ok. |
ocean90
Oct 3, 2017
Member
Can we ignore the variants part in this PR for now?
Can we ignore the variants part in this PR for now?
toolstack
Oct 3, 2017
Author
Contributor
Not easily without breaking one or both of the patches :)
They both do a lot of work on the locales file so separating them is hard.
Not easily without breaking one or both of the patches :)
They both do a lot of work on the locales file so separating them is hard.
} | ||
} | ||
} | ||
} // End foreach(). |
ocean90
Oct 3, 2017
Member
These are no longer required and can be removed.
These are no longer required and can be removed.
toolstack
Oct 3, 2017
Author
Contributor
👍
$root_var_name = str_replace( '-', '_', $locale->variant_root ); | ||
|
||
// Output the first line to 'create' the GP_Locale object for this locale. | ||
echo "\t\t\${$var_name} = new GP_Locale();\n"; // WPCS: XSS ok. |
ocean90
Oct 3, 2017
Member
Remove all // WPCS: XSS ok.
comments and add the bin directory as a exclude-pattern to phpcs.xml.
Remove all // WPCS: XSS ok.
comments and add the bin directory as a exclude-pattern to phpcs.xml.
toolstack
Oct 3, 2017
Author
Contributor
👍
} | ||
} | ||
} | ||
} // End foreach(). |
ocean90
Oct 3, 2017
Member
These are no longer required and can be removed.
These are no longer required and can be removed.
toolstack
Oct 3, 2017
Author
Contributor
👍
2a41a26
to
5a3ec10
44f8127
to
e171d3a
@@ -12,6 +12,9 @@ | |||
<dt><label for="project[description]"><?php _e( 'Description', 'glotpress' ); ?></label> <span class="ternary"><?php _e( 'can include HTML', 'glotpress' ); ?></span></dt> | |||
<dd><textarea name="project[description]" rows="4" cols="40" id="project[description]"><?php echo esc_html( $project->description ); ?></textarea></dd> | |||
|
|||
<dt><label for="project[plurals_type]"><?php _e( 'Plurals Type', 'glotpress' ); ?></label></dt> | |||
<dd><?php echo gp_plural_types_dropdown( 'project[plurals_type]', $project->plurals_type, array() ); // WPCS: XSS ok. ?></dd> |
ocean90
Apr 8, 2018
Member
The // WPCS: XSS ok
seems to be obsolete.
The // WPCS: XSS ok
seems to be obsolete.
The current locale alignment doesn't match our code styling. Example:
produces:
It needs to be:
|
$af->cldr_code = 'af'; | ||
$af->cldr_nplurals = '2'; | ||
$af->cldr_plural_expressions['one'] = 'n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000'; | ||
$af->cldr_plural_expressions['other'] = ' @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …'; |
ocean90
Apr 8, 2018
Member
Is the leading whitespace required?
Is the leading whitespace required?
toolstack
May 17, 2018
Author
Contributor
I don't think so but it's in the original JSON file from the CLDR repo so I think it's safer to leave in.
I don't think so but it's in the original JSON file from the CLDR repo so I think it's safer to leave in.
@@ -162,6 +274,11 @@ private function add_schema_info() { | |||
$this->line('-->', 1 ); | |||
} | |||
|
|||
/** | |||
* Cteate the .resx schema declaration. .resx file have a standard scheam declaration. |
GaryJones
Apr 9, 2018
Several typos here.
Several typos here.
toolstack
May 17, 2018
Author
Contributor
Fixed.
Fixed.
private function escape( $string ) { | ||
$string = str_replace( array( '&', '<' ), array( '&', '<' ), $string ); | ||
return $string; | ||
} | ||
|
||
|
||
/** | ||
* Cteate the .resx schema info. .resx file have a standard scheam block. |
GaryJones
Apr 9, 2018
Several typos here.
Several typos here.
toolstack
May 17, 2018
Author
Contributor
Fixed.
Fixed.
in the current version of phpcs (see https://github.com/squizlabs/PHP_CodeSniffer/issues/1731) | ||
which breaks this when a single file name is passed to be checked (for example with TravisCI). | ||
A fix has been committed and will be included in phpcs version 3.2, however this is no release |
GaryJones
Apr 9, 2018
PHPCS 3.2 was released in December 2017, and the latest release is 3.2.3, with 3.3.0 not too far away. It would be reasonable to make ^3.2
the minimum version of PHPCS required for devs to contribute to GlotPress.
PHPCS 3.2 was released in December 2017, and the latest release is 3.2.3, with 3.3.0 not too far away. It would be reasonable to make ^3.2
the minimum version of PHPCS required for devs to contribute to GlotPress.
toolstack
May 17, 2018
Author
Contributor
This should have automatically taken care of itself, we just have to remove the extra lines now as they were only needed before 3.2 was released.
This should have automatically taken care of itself, we just have to remove the extra lines now as they were only needed before 3.2 was released.
dcbfaf9
to
83b45fe
And add a minor comment to the locale generator.
Rename dropdown function and PHP CS rule additions. Fix error.
Import not yet implemented.
Now appends the code around the locales list to make life easier.
To create no-variants version of the locales file and also write both out to files instead of the console. Also make a backup just in case before deleting the old file.
7264bcb
to
e7c0296
toolstack commentedJul 7, 2017
Resolves #666.