Fix language name display for non-PT/EN/ES languages in article menus#440
Draft
Fix language name display for non-PT/EN/ES languages in article menus#440
Conversation
- Update trans_alpha2 filter to fallback to LANG_NAMES ISO English names - Add German (de/Alemão) to ISO3166_ALPHA2 dict - Update all level menu templates to use trans_alpha2 filter and uppercase ISO codes - Add language name translations for FR, DE, IT, RU, AR, ZH, RO to all locales - Add tests for trans_alpha2 filter Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com>
…nit__.py change Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix interface handling for articles with translations in other languages
Fix language name display for non-PT/EN/ES languages in article menus
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
O que esse PR faz?
Article menus (Resumo, Texto, PDF) only handled PT/EN/ES language names via hardcoded
if/elifchains. Any other language (FR, DE, RU, etc.) fell back to raw ISO codes or native script names instead of interface-translated names.This PR replaces the per-language conditionals with the existing
trans_alpha2Jinja2 filter across all menu templates, and enhances the filter with a fallback toLANG_NAMES(180+ languages).Changes:
choices.py— Addedde(Alemão) toISO3166_ALPHA2custom_filters.py—trans_alpha2now falls back to ISO English name fromLANG_NAMESwhen code isn't inISO3166_ALPHA2levelMenu.html,levelMenu_abstracts.html,levelMenu_texts.html,levelMenu_pdf.html) — Replaced hardcoded PT/EN/ES branches:{{ lang|upper }}(e.g.,FR,DE){{ lang|trans_alpha2 }}(e.g., Francês → French/Francés per interface).poentries for Francês, Alemão, Italiano, Russo, Árabe, Chinês, Romeno, Albanês across all 6 localesTransAlpha2TestCasecovering dict lookup, LANG_NAMES fallback, comma-separated names, unknown codesOnde a revisão poderia começar?
opac/webapp/main/custom_filters.py— the enhancedtrans_alpha2filter, then the simplified templates.Como este poderia ser testado manualmente?
FR)Algum cenário de contexto que queira dar?
Before:
{% if lang == 'es' %} ... {% elif lang == 'en' %} ... {% else %} {{ abstract['language'] }} {% endif %}— any language outside the three hardcoded ones showed raw codes likefror native names likeFrançais.After:
{{ lang|trans_alpha2 }}— works for all languages, translates to interface language for common ones, falls back to English ISO name for rare ones.Screenshots
N/A — requires running application with MongoDB and article data with non-PT/EN/ES translations.
Quais são tickets relevantes?
Interface não lida bem com artigos com traduções em idiomas que não PT, EN ou ES
Referências
opac/webapp/config/lang_names.pytrans_alpha2filter usage inopac/webapp/templates/issue/toc.htmlOriginal prompt
This section details on the original issue you should resolve
<issue_title>Interface não lida bem com artigos com traduções em idiomas que não PT, EN ou ES</issue_title>
<issue_description>### Descrição do problema
Quando um artigo possui tradução do resumo e/ou HTML e PDF em idiomas que não português, espanhol ou inglês, o nome do idioma não segue o idioma da interface, mostrando ou o código ISO ou o nome do idioma no idioma propriamente dito.
Passos para reproduzir o problema
Demonstração do problema: https://youtu.be/XnpcAI93icQ
Comportamento esperado
O comportamento esperado é o mesmo que ocorre para artigos com tradução do resumo e/ou HTML e PDF em português, espanhol ou inglês.
Algo que não mencionei no vídeo é que para o menu TEXTO, quando estiver colapsado, é preciso mostrar o código ISO do idioma selecionado em caixa alta, não o nome do idioma escrito por extenso, mas o nome dos idiomas escrito por extenso deve aparecer no idioma da interface quando o menu estiver expandido.
Ambiente utilizado
O problema acontece em desktop e mobile.
</issue_description>
Comments on the Issue (you are @copilot in this section)
@robertatakenaka @carolinatanigushi o que melhor ajuda na hora de reportar problema é a objetividade. O vídeo ilustra bem o problema, mas não fica claro o que se espera. É necessário revisar N vezes o vídeo para pegar detalhes não compreendidos na primeira vez. Então, em resumo, escreva um exemploInterface em Espanhol
Conteúdo em Alemão
Como ficariam as opções de menu para resumo, texto, pdf?
Adicione os links dos artigos acessados no vídeo</comment_new>
<comment_new>@carolinatanigushi
@robertatakenaka Respondo a seguir,
@carolinatanigushi o que melhor ajuda na hora de reportar problema é a objetividade. O vídeo ilustra bem o problema, mas não fica claro o que se espera. É necessário revisar N vezes o vídeo para pegar detalhes não compreendidos na primeira vez. Então, em resumo, escreva um exemplo
Como ficariam as opções de menu para resumo, texto, pdf?
Ou seja, se temos, por exemplo, um artigo com resumo em PT, EN e FR, com HTML e PDF em PT e FR, o menu deve aparecer da seguinte forma:
INTERFACE PT
Resumo
Texto (FR)
PDF
INTERFACE EN
Abstract
Text (FR)
PDF
INTERFACE ES
Resumen
Texto (FR)
PDF
Adicione os links dos artigos acessados no vídeo
@robertatakenaka @carolinatanigushi ficou claro. Dar o exemplo do primeiro artigo pode ficar confuso porque os idiomas do conteúdo são os mesmos da interface. Funciona melhor exemplificar com um idioma do conteúdo diferente do da interface. @robertatakenaka @samuelveigarangel apoiar o Luciano para a solução disso📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.