Skip to content

Import the local pages as GlotPress' projects#1856

Draft
amieiro wants to merge 132 commits intoGlotPress:localfrom
amieiro:local-import-pages
Draft

Import the local pages as GlotPress' projects#1856
amieiro wants to merge 132 commits intoGlotPress:localfrom
amieiro:local-import-pages

Conversation

@amieiro
Copy link
Member

@amieiro amieiro commented Aug 15, 2024

Problem

The WordPress.org projects needs to be able to translate the documentation from English to another languages. We have had a few meetings (WCEU 2023, WCEU 2024) and we want to test GlotPress as the translation engine.

Solution

This PR is a first step, doing these steps:

  • Add a list of pages in the GlotPress backend, so the GTE will be able to import to GlotPress with a button.
  • Import the pages into GlotPress, splitting each block as an original string.
  • Export the translated content into a new page.

Screenshots or screencast

Local GlotPress

image

Original page

image

Translation page in GlotPress

image

Translated page

image

amieiro and others added 30 commits May 29, 2024 04:49
- Development
- Continents and cities
- Administration
- Network admin
* Add the backend with settings and a list with local items (core, plugins, themes)

* Save the checkbox value to enable local translations

* Add a message to hide the local translations if you have not enable them

* Add the originals and the translations strings for the core

* Split the translate_core method in smaller methods

* Add the 4 WordPress core subprojects and the main project.

* Add the functionality to translate locally a plugin

* Add the functionality to translate locally a theme

* Redirect to the selected plugin or theme, not to the main project

* Add the nonces in the URL and their checks

* Add some checks

* Download the .po and .mo files from translate.w.org if they don't exist locally

* Redirect to the locale in the plugins and themes

* Check if the file downloaded from DotOrg has fired an error

* Add the local "languages" folder inside the plugins and themes to look for .po files

* Initial import of community-translator

* Preload translations

* Make saving work

* Fix lint errors

* JS Lint fixes

* Fix eslint errors

* Update for new eslint settings

* Incorporate text domain namespacing more deeply

* Lint fixes

* Lint fix

* fix warning

* Fix wrong parameter sequence

* typo

* Fix original lookup

* Speedup initial tree walking

* Looku placeholders

* Show user translations

* Modify translation after saving

* Fix linting

* Prioritize found translations when the context is dubious

* Remove help icon for now

* Expose the text domain for translations that were not found

* Don't replace placeholders as if they were new translations

---------

Co-authored-by: Jesús Amieiro <1667814+amieiro@users.noreply.github.com>
* Implement a REST API for saving translations

* Remove some outdated default settings
* Inline Translation: Make it work in the customizer

* lint
)

* Improve multi-placeholder translation replacement

* Fix case where the output text was already a translation

* lint

* Initialize array

* Add renamed core projects

* Update new project paths
* Improve multi-placeholder translation replacement

* Fix case where the output text was already a translation

* lint

* Unify project creation

* Continued unification

* Improve behavior with an empty Local GlotPress

* Fix insertion of JS placeholders

* Improve button text

* Update assets

* Fix rebase error

* Lint fixes

* Add a welcome page

* Lint fixes

* typo

* Rename WordPress project to just WordPress

* Make more strings translatable

* Allow some HTML in descriptions

* Fix lint

* Require local GlotPress to be active for inline translation

* Fix lint

* Remove actions column if there are no actions

* Replace modified strings back in again

* Fix another edge case with reinsering translations

* Fix another edge case
* Add a Sync to w.org view

* Rename to Contribute back

* Linting

* Prototype the translation processing

* Generate PO files

* Filter the target URL
@adamziel
Copy link

adamziel commented Sep 9, 2024

Thinking about using Playground for editing WordPress Documentation, one of the possible data flows is importing markdown documentation files from a GitHub repository into Playground, making edits, and then creating a Pull Request directly from Playground.

I wonder how we could make the two workflows compatible, so enable translating documentation pages brought over from markdown files from GitHub. We have a two-way markdown<->blocks conversion pipeline at https://github.com/dmsnell/blocky-formats so we can reason about blocks instead of text paragraphs. Would that suffice? Or would we have store some additional structured data in the repo to cross-reference paragraphs/blocks from different markdown files?

@akirk
Copy link
Member

akirk commented Sep 30, 2024

@amieiro and I discussed that the current implementation on writing <data> tags to block HTML currently breaks editing the translated blocks as they are all flagged for invalidity.

Possible solution: add the metadata to the block attribute json (for example as fake css class names so that they remain after editing the page gp-original-123) and convert it to a element upon output by getting the data from the database. A positive aspect of this is that we can do this transformation only for people with permission (= logged in users).

@adamziel
Copy link

adamziel commented Sep 30, 2024

Would the meta attribute work? Or storing it as a block binding?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants