Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to disable fuzzy translations for similar string import #630

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rename filter
  • Loading branch information
yoavf committed Jan 3, 2017
commit 5673c2a5d56cc962162051e725e7439510c12f36
2 changes: 1 addition & 1 deletion gp-includes/things/original.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function import_for_project( $project, $translations ) {
* @param object $data The new original data.
* @param object $original The previous original being replaced.
*/
$do_fuzzy = apply_filters( 'gp_close_original_fuzzy_translations', true, (object) $data, $original );
$do_fuzzy = apply_filters( 'gp_set_translations_for_original_to_fuzzy', true, (object) $data, $original );

// We'll update the old original...
$this->update( $data, array( 'id' => $original->id ) );
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/testcases/tests_things/test_thing_original.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ function test_import_should_not_mark_translation_of_changed_strings_as_fuzzy_wit
$translation = $this->factory->translation->create( array( 'translation_set_id' => $set->id, 'original_id' => $original->id, 'status' => 'current' ) );
$translations_for_import = $this->create_translations_with( array( array( 'singular' => 'baba baba.' ) ) );

add_filter( 'gp_close_original_fuzzy_translations', '__return_false' );
add_filter( 'gp_set_translations_for_original_to_fuzzy', '__return_false' );

list( $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted, $originals_error ) = $original->import_for_project( $set->project, $translations_for_import );

remove_filter( 'gp_close_original_fuzzy_translations', '__return_false' );
remove_filter( 'gp_set_translations_for_original_to_fuzzy', '__return_false' );

$this->assertEquals( 0, $originals_added );
$this->assertEquals( 1, $originals_existing );
Expand Down