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

Account for all existing translation keys #538

Open
wbazant opened this issue Oct 24, 2024 · 2 comments
Open

Account for all existing translation keys #538

wbazant opened this issue Oct 24, 2024 · 2 comments
Labels
epic Very important big issue translation

Comments

@wbazant
Copy link
Collaborator

wbazant commented Oct 24, 2024

We have translations for lots of different verbiage accompanying functionality on the live site, and before we start asking volunteers for new translations, we want to make sure we have leveraged what we have. Additionally, comparing translation keys is going to help us track progress for the beta release milestone - things like a little help icon somewhere on the live site that will still be useful on the beta site.

This epic will conclude where for each translation key on the live site ( currently 354 of them ) we'll either have it on the beta site, or we'll tie it to a feature that we're consciously not carrying forward. We can also stop when the epic no longer helps us identify changes worth making to the beta site :).

@wbazant
Copy link
Collaborator Author

wbazant commented Oct 24, 2024

Here's a slightly imperfect one liner that finds all translations in the source code:

find src -type f | xargs perl -nE 'say for m{t\((?:['"'"'"])(.+?)(?:['"'"'"])}g' | grep -v '^/' | sort -u

and this one (assuming we are still in a directory falling-fruit-web, and there's a falling-fruit directory next to it) prints all keys in the yaml:

perl -MYAML::XS -e 'sub print_keys { my ($data, $prefix) = @_; if (ref($data) eq "HASH") { foreach my $key (keys %$data) { if (!ref($data->{$key})) { print "$prefix$key\n"; } print_keys($data->{$key}, "$prefix$key."); } } elsif (ref($data) eq "ARRAY") { foreach my $index (0 .. $#{$data}) { print_keys($data->[$index], "$prefix$index."); } } } print_keys(YAML::XS::LoadFile($ARGV[0]), "");' ../falling-fruit/config/locales/en.yml | perl -nE 'say $1 if /en\.(.*)/' | sort

Combining both, and printing in a three-column format for just beta site, just live site, and shared keys:

comm <( find src -type f | xargs perl -nE 'say for m{t\((?:['"'"'"])(.+?)(?:['"'"'"])}g' | grep -v '^/' | sort -u ) <(  perl -MYAML::XS -e 'sub print_keys { my ($data, $prefix) = @_; if (ref($data) eq "HASH") { foreach my $key (keys %$data) { if (!ref($data->{$key})) { print "$prefix$key\n"; } print_keys($data->{$key}, "$prefix$key."); } } elsif (ref($data) eq "ARRAY") { foreach my $index (0 .. $#{$data}) { print_keys($data->[$index], "$prefix$index."); } } } print_keys(YAML::XS::LoadFile($ARGV[0]), "");' ../falling-fruit/config/locales/en.yml | perl -nE 'say $1 if /en\.(.*)/' | sort ) | grep pages
		pages.about.about_the_site
		pages.about.advisors
		pages.about.alan_gibson_bio_html
		pages.about.ana_carolina_bio_html
		pages.about.caleb_phillips_bio_html
		pages.about.celebration
		pages.about.closing_remarks
		pages.about.closing_remarks_para1_html
		pages.about.closing_remarks_para2_html
		pages.about.closing_remarks_para3_html
		pages.about.contact_us_html
		pages.about.craig_durkin_bio_html
		pages.about.cristina_rubke_bio_html
		pages.about.david_craft_bio_html
		pages.about.directors
		pages.about.emily_sigman_bio_html
		pages.about.ethan_welty_bio_html
		pages.about.ff_disclaimer_html
	pages.about.give_gratipay
		pages.about.give_paypal
		pages.about.give_us_money
		pages.about.jeff_wanner_bio_html
		pages.about.join_us_html
		pages.about.more_about_html
		pages.about.staff
		pages.about.translate
		pages.about.translate_for_us_html
		pages.about.translators
		pages.about.tristram_stuart_bio_html
		pages.about.write
pages.data
	pages.data.beware_html
	pages.data.caveat_emptor_html
	pages.data.data_unavailable_html
	pages.data.intro
	pages.data.license_html
	pages.datasets.community_map
	pages.datasets.date_imported
	pages.datasets.google_fusion_table
	pages.datasets.google_map
	pages.datasets.google_maps_engine
	pages.datasets.intro_html
	pages.datasets.no_license
	pages.datasets.table_info
	pages.datasets.type
	pages.datasets.types_of_data
	pages.data.summary_description
	pages.data.summary_of_sources
pages.press
pages.project
pages.sharing
	pages.sharing.ample_harvest
	pages.sharing.food_banks
	pages.sharing.food_banks_canada
	pages.sharing.food_banks_intro
	pages.sharing.global_foodbanking_network
	pages.sharing.grow_pick_and_distribute
	pages.sharing.intro_html

@wbazant wbazant assigned wbazant and unassigned wbazant Oct 24, 2024
@wbazant wbazant added the epic Very important big issue label Oct 24, 2024
@ezwelty
Copy link
Collaborator

ezwelty commented Oct 25, 2024

@wbazant I'll mention here that there are also a few additional translation keys associated with the mobile app (https://github.com/falling-fruit/falling-fruit-mobile/tree/main/www/locales).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Very important big issue translation
Projects
None yet
Development

No branches or pull requests

2 participants