GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add function to compare translated strings between two commits by guilhermesrc · Pull Request #138 · python/python-docs-pt-br

Conversation

@guilhermesrc

@guilhermesrc guilhermesrc commented Nov 10, 2023

Copy link
Copy Markdown

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@guilhermesrc
Add function to compare translated strings between two commits
240fb08
adorilson
adorilson reviewed Nov 11, 2023
View reviewed changes
Comment thread .github/scripts/get_translated_strings_between_commits.py Outdated
try:
commit_hash1_count = get_translated_commit_strings(commit_hash1)
commit_hash2_count = get_translated_commit_strings(commit_hash2)
return abs(commit_hash1_count - commit_hash2_count)

@adorilson adorilson Nov 11, 2023

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@rffontenelle faz sentido esse abs aqui?

Esse commits tanto podem ser novas strings quanto strings traduzidas, certo?
Neste caso, saber o sinal eu acho válido.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@guilhermesrc guilhermesrc Nov 11, 2023

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Faz sentido, me esqueci que poderiam chegar novas strings

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rffontenelle rffontenelle Nov 13, 2023

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Neste caso específico, acredito que "se negativo, retorna 0" seria mais adequado. Significa, provavelmente, que temos novas strings não traduzidas

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
adorilson
adorilson reviewed Nov 11, 2023
View reviewed changes
Comment thread .github/scripts/get_translated_strings_between_commits.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adorilson

adorilson commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

Este PR é pra resolver #135, certo?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@guilhermesrc

guilhermesrc commented Nov 11, 2023

Copy link
Copy Markdown
Author

isso

adorilson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rffontenelle

rffontenelle commented Nov 12, 2023

Copy link
Copy Markdown
Collaborator

Ao invés de executar pocount para cada arquivo PO e ir adicionando as strings, que tal executar pocount em todos de uma só vez e pegar apenas o total?

$ pocount *.po **/*.po
Processing file : about.po
Type               Strings      Words (source)    Words (translation)
Translated:      10 (100%)        166 (100%)             170
Fuzzy:            0 (  0%)          0 (  0%)             n/a
Untranslated:     0 (  0%)          0 (  0%)             n/a
Total:           10               166                    170

Unreviewed:      10 (100%)        166 (100%)             170

# ....
# pulei para o final

Processing file : whatsnew/index.po
Type               Strings      Words (source)    Words (translation)
Translated:       3 (100%)         69 (100%)              78
Fuzzy:            0 (  0%)          0 (  0%)             n/a
Untranslated:     0 (  0%)          0 (  0%)             n/a
Total:            3                69                     78

Unreviewed:       3 (100%)         69 (100%)              78

Processing file : TOTAL:
Type               Strings      Words (source)    Words (translation)
Translated:   27887 ( 50%)     476230 ( 42%)          503086
Fuzzy:            0 (  0%)          0 (  0%)             n/a
Untranslated: 27775 ( 49%)     653717 ( 57%)             n/a
Total:        55662           1129947                 503086

File count:     483

Pode-se corresponder ao texto "TOTAL:" como marcador de inicío para considerar a leitura de conteúdo e aí buscar correspondência do padrão pattern_translated_strings. Seria, assim, uma execução do pocount por commit.

Nota: git ls-files é uma alternativa para assegurar que apenas arquivos .po rastreados pelo repositório git sejam inclusivos. Mas talvez não seja necessário.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@guilhermesrc
Merge branch 'python:3.12' into 3.12
e608405
@guilhermesrc

guilhermesrc commented Nov 13, 2023

Copy link
Copy Markdown
Author

Nessa ideia, como poderia ser pego o pocount total de um commit antigo? não consegui achar nada a respeito.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rffontenelle

rffontenelle commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

Nessa ideia, como poderia ser pego o pocount total de um commit antigo? não consegui achar nada a respeito.

git switch com --detach. Por exemplo: git switch d16bd17181b2cc50d822eecbca9b13c51903dc7e --detach. Para voltar: git switch 3.12.

Para obter o branch atual, use git branch --show-current (me parece melhor que forçar via código um branch).

Outra opção é usar a biblioteca GitPython.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

guilhermesrc added 5 commits November 13, 2023 14:32
@guilhermesrc
testando outra forma de obter as strings do commit
c1a0135
@guilhermesrc
retirando o contexto
f5e5051
@guilhermesrc
mudando a forma como é pego o commit strings
bbc6015
@guilhermesrc
refatorando run_os_command e get_translated_strings_between_commits.py
a77da15
@guilhermesrc
retirando dependencia não usada
1ad887c
@guilhermesrc

guilhermesrc commented Nov 13, 2023

Copy link
Copy Markdown
Author

refatorei sobre aqueles aspectos do git switch, acredito que ainda falte o "se negativo, retorna 0"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adorilson

adorilson commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

refatorei sobre aqueles aspectos do git switch, acredito que ainda falte o "se negativo, retorna 0"

Isso faz mesmo sentido, @rffontenelle ? Pra mim, não faz. Qual é a informação que você tem que eu não tenho? :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adorilson

adorilson commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

@guilhermesrc

E eu acho que tá dando uma exagerada no uso de try...except. Quais são as exceções possíveis?
Capturar Exception não é uma boa prática.

E depois retornar 0 pode dar algum tipo de confusão com "se negativo" ou "nada mudou mesmo".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rffontenelle

rffontenelle commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

refatorei sobre aqueles aspectos do git switch, acredito que ainda falte o "se negativo, retorna 0"

Isso faz mesmo sentido, @rffontenelle ? Pra mim, não faz. Qual é a informação que você tem que eu não tenho? :)

Vamos para um exemplo.

Quinta-feira temos 20000 traduzidas. Sexta-feira as strings fontes foram atualizadas e alterações resultaram agora em termos 19900 porque pequenas alterações em strings existentes, "apagando" a tradução.

Neste caso, subtrair 19900 de 20000 (atual menos o anterior) vai dar 100 negativo. Aqui a diferença não é zero somente porque "perdemos tradução" (ainda aparecem como sugestões do Transifex). Neste caso, acho que podemos considerar zero tradução.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adorilson

adorilson commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

refatorei sobre aqueles aspectos do git switch, acredito que ainda falte o "se negativo, retorna 0"

Isso faz mesmo sentido, @rffontenelle ? Pra mim, não faz. Qual é a informação que você tem que eu não tenho? :)

Vamos para um exemplo.

Quinta-feira temos 20000 traduzidas. Sexta-feira as strings fontes foram atualizadas e alterações resultaram agora em termos 19900 porque pequenas alterações em strings existentes, "apagando" a tradução.

Neste caso, subtrair 19900 de 20000 (atual menos o anterior) vai dar 100 negativo. Aqui a diferença não é zero somente porque "perdemos tradução" (ainda aparecem como sugestões do Transifex). Neste caso, acho que podemos considerar zero tradução.

Então... isso não deveria ser -100?

Porque agora temos a certeza que há 100 novas strings pra traduzir, seja porque são realmente novas, seja porque algo que estava traduzido deixou de estar (o motivo me parece irrelevante). E aí sabemos que há trabalho de tradução pra ser feito. Se eu vejo 0, vou ignorar.

Isto é, tou pensando no caso de uso disso ser útil pra saber o que precisa ser traduzido. De repente, você tá pensando em outro caso de uso.

Vendo o título do PR e também a descricao em #135 parece que é isso mesmo... você focou no caso pontual de saber quanto traduzimos em uma sprint (e aí não faz sentido dizer "destraduzimos X strings") e eu pensei em comparar dois commits quaisquer...

Se possível, eu agora quero os dois. :D

Deixaria essas funções já feitas como estão, para esse cenários mais amplo que eu pensei, e escreveria nova(s) para esse caso do "se negativo, retorna 0"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@guilhermesrc

guilhermesrc commented Nov 13, 2023

Copy link
Copy Markdown
Author

@guilhermesrc

E eu acho que tá dando uma exagerada no uso de try...except. Quais são as exceções possíveis? Capturar Exception não é uma boa prática.

E depois retornar 0 pode dar algum tipo de confusão com "se negativo" ou "nada mudou mesmo".

Nossa realmente ficou bem genérico revisando, mais tarde reescrevo. Agora pensando, talvez no regex e ao manipular o OS ali seriam as exceções mais validas.

adorilson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@guilhermesrc
alterando biblioteca de manipulação com o sistema e retirando try exc…
964d587
…epts desnecessarios
@guilhermesrc

guilhermesrc commented Nov 13, 2023

Copy link
Copy Markdown
Author

Tirei quase todos os exceptions, exceto a de manipulação do sistema, somente alterei a biblioteca.

adorilson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adorilson adorilson adorilson left review comments
@rffontenelle rffontenelle rffontenelle left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@guilhermesrc @adorilson @rffontenelle
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.