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

cleanup extract-db-locale-terms.php script #6960

Merged
merged 14 commits into from
May 10, 2024

Conversation

DAcodedBEAT
Copy link
Contributor

Description & Issue number it closes

@respencer and I chatted and found some areas for cleanup in this script

How to test the changes?

N/A

@DAcodedBEAT DAcodedBEAT requested a review from a team as a code owner April 24, 2024 22:11
@DAcodedBEAT DAcodedBEAT requested review from DawoudIO, grayeul and MrClever and removed request for a team April 24, 2024 22:11
@DAcodedBEAT DAcodedBEAT added Code Smell php Pull requests that update Php code labels Apr 24, 2024
@DawoudIO
Copy link
Contributor

Does the outcome change

@DAcodedBEAT
Copy link
Contributor Author

Does the outcome change

No and that's the point - to ensure the outcome is consistently the same regardless of what platform ran it.

@DAcodedBEAT DAcodedBEAT added this to the vNext (5.8.0) milestone Apr 25, 2024
Copy link
Contributor

@DawoudIO DawoudIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a test on my local box, there are missing terms (countries) and the order has been changed...

@DAcodedBEAT
Copy link
Contributor Author

I did a test on my local box, there are missing terms (countries) and the order has been changed...

I don't see how this change and the results you've seen are related

@respencer
Copy link
Contributor

I did a test on my local box, there are missing terms (countries) and the order has been changed...

Is the order important?

I'm making some changes of my own that I hope to push soon, and it would be better if the part of the job that needs database access runs first.

Then if it fails nothing else runs.

Right now you can have an inconsistent end result due to partial failure.

If order is important I can change it so the database part runs first, but it assembles the files in the correct order.

@DawoudIO
Copy link
Contributor

oder is not important as long it does not change from run to run... this way we can tell what changed...

@respencer
Copy link
Contributor

I did a test on my local box, there are missing terms (countries) and the order has been changed...

I just did a build test going back to commit d88ef89 and there is still a change of order and missing countries. Very odd.

Checking the last committed version of locale/messages.po I see some change of order, but the countries are there.

I'll continue investigating.

@respencer
Copy link
Contributor

After those changes all the missing data is back again, but the order is still different.

Unless sort has somehow changed its behaviors:

find . -iname '*.php' | sort | grep -v ./vendor | xargs xgettext --no-location --no-wrap --from-code=UTF-8 -o ../locale/messages.po -L PHP

I have no idea how the previous order came about.

@respencer
Copy link
Contributor

Best guess is something else has sorted the last committed messages.po file contents by the age of the original file.

A strictly alphabetical sort of the file names would have all the api message strings first, which is what I'm getting.

@DawoudIO
Copy link
Contributor

does this address #1432

@DAcodedBEAT
Copy link
Contributor Author

does this address #1432

@DawoudIO no, this is strictly for the machine running the script. \r existing in translations are due to inputs in the translations themselves

@respencer
Copy link
Contributor

does this address #1432

@DawoudIO no, this is strictly for the machine running the script. \r existing in translations are due to inputs in the translations themselves

Why are we not replacing \r with \n, so those warnings stop?

@DAcodedBEAT
Copy link
Contributor Author

does this address #1432

@DawoudIO no, this is strictly for the machine running the script. \r existing in translations are due to inputs in the translations themselves

Why are we not replacing \r with \n, so those warnings stop?

Alternatively, we fix the 1 bad locale which has \r - /~https://github.com/ChurchCRM/CRM/blob/master/src/locale/textdomain/es_ES/LC_MESSAGES/messages.po#L4656

@respencer
Copy link
Contributor

does this address #1432

@DawoudIO no, this is strictly for the machine running the script. \r existing in translations are due to inputs in the translations themselves

Why are we not replacing \r with \n, so those warnings stop?

Alternatively, we fix the 1 bad locale which has \r - /~https://github.com/ChurchCRM/CRM/blob/master/src/locale/textdomain/es_ES/LC_MESSAGES/messages.po#L4656

Okay, that to needs to be fixed. My understanding is \r is not allowed in gettext -- \n is.

The translation system will translate \n to \r on a system that needs it, but \n is the only valid line ending that is allowed to be stored.

So we need to replace \r, and \r with \n to have those warnings go away as the gettext strings will then be completely valid.

@DAcodedBEAT
Copy link
Contributor Author

does this address #1432

@DawoudIO no, this is strictly for the machine running the script. \r existing in translations are due to inputs in the translations themselves

Why are we not replacing \r with \n, so those warnings stop?

Alternatively, we fix the 1 bad locale which has \r - /~https://github.com/ChurchCRM/CRM/blob/master/src/locale/textdomain/es_ES/LC_MESSAGES/messages.po#L4656

Translated this string:

Session time limit in seconds\rSet to zero to disable session time limits.

🤦

@DAcodedBEAT DAcodedBEAT force-pushed the cleanup-extract-db-locale-terms branch from 8411b5d to 3dee8a2 Compare May 2, 2024 19:18
@DAcodedBEAT DAcodedBEAT force-pushed the cleanup-extract-db-locale-terms branch from 3dee8a2 to 158e831 Compare May 3, 2024 13:38
@DAcodedBEAT DAcodedBEAT requested review from respencer and DawoudIO May 3, 2024 17:23
Copy link
Contributor

@DawoudIO DawoudIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running the script on main

image

vs on the branch

image

Please test and diff the output of messages.po

@respencer respencer requested a review from DawoudIO May 7, 2024 18:20
@DAcodedBEAT
Copy link
Contributor Author

@DawoudIO is this good to go on your end? I think @respencer fixed the issue you found

@DAcodedBEAT DAcodedBEAT merged commit c6d8384 into master May 10, 2024
4 checks passed
@DAcodedBEAT DAcodedBEAT deleted the cleanup-extract-db-locale-terms branch May 10, 2024 19:14
respencer added a commit to respencer/ChurchCRM that referenced this pull request May 13, 2024
# Description & Issue number it closes 
<!-- Please include a summary of the changes and the related issue.
Please also include relevant motivation and context. -->

@respencer and I chatted and found some areas for cleanup in this script

## How to test the changes?

N/A

---------

Co-authored-by: Robert Spencer <respencer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Smell php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants