Skip to content

Commit 7c780d1

Browse files
authored
Merge pull request #15648 from nextcloud/docs/translation-hints-contributor-workflow
docs(translations): fix the context-hints intro and add a contribution path for non-developers
2 parents 1e30a96 + b65935e commit 7c780d1

5 files changed

Lines changed: 148 additions & 4 deletions

File tree

‎developer_manual/basics/translations.rst‎

Lines changed: 148 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,11 @@ This allows translators to have the cloudlink before the browselink in case the
304304
Provide context hints for translators
305305
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
306306

307-
In case some translation strings may be translated wrongly because they have multiple meanings.
308-
Especially translations strings that only contain a single word often result in problems.
309-
The most famous example in the Nextcloud code base is ``Share`` which can which can be the verb and action ``To share something`` or the noun ``A share``.
310-
The added hints will be shown in the Transifex web-interface:
307+
Some translation strings can be translated wrongly because they have multiple meanings.
308+
Strings that contain only a single word are especially prone to this.
309+
The most famous example in the Nextcloud code base is ``Share``, which can be the verb and action
310+
``To share something`` or the noun ``A share``.
311+
Adding a context hint resolves the ambiguity, and the hint is shown to translators in the Transifex web interface.
311312

312313
.. warning::
313314

@@ -376,6 +377,16 @@ In the ``<template>`` block, use an HTML comment on the line above the element:
376377

377378
In the ``<script>`` block, use the same ``//`` style as JavaScript.
378379

380+
.. note::
381+
382+
The marker depends on the extraction toolchain, and the examples below are **not** all
383+
``TRANSLATORS``. The gettext-based projects - PHP, JavaScript/TypeScript and Vue - require the
384+
comment to start with ``TRANSLATORS``, because that is the prefix the extractor is configured to
385+
look for. Android uses a plain XML comment and ``TRANSLATORS`` there is a project convention
386+
rather than a requirement. **Qt and iOS use their own markers** - ``//:`` for ``lupdate`` and a
387+
``/* ... */`` comment for the iOS string tooling - and writing ``TRANSLATORS`` in those files
388+
produces no hint at all, because the extractor never looks for it.
389+
379390
C++ (Qt) / Desktop client
380391
"""""""""""""""""""""""""
381392

@@ -400,6 +411,139 @@ iOS
400411
/* The title on the navigation bar of the Scanning screen. */
401412
"wescan.scanning.title" = "Scanning";
402413
414+
Contributing a context hint without a local checkout
415+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
416+
417+
Context hints are one of the few code changes that are worth making even if you do not develop
418+
Nextcloud. Translators are usually the people who notice that a string is ambiguous, and a hint is a
419+
single comment line. You do not need git, a development environment or a checkout to add one - the
420+
GitHub web editor is enough.
421+
422+
Find the string
423+
"""""""""""""""
424+
425+
Search the repository the string belongs to for the text in quotes. If you do not know which
426+
repository that is, the Transifex resource name matches the app: a string in the ``files_external``
427+
resource lives in ``apps/files_external/`` in ``nextcloud/server``, and a string in the ``deck``
428+
resource lives in ``nextcloud/deck``.
429+
430+
Edit the file
431+
"""""""""""""
432+
433+
Open the file on GitHub and click the pencil icon.
434+
435+
Unless you are a member of the Nextcloud organisation, you will not land in the editor. GitHub stops
436+
you with **"You need to fork this repository to propose changes"** and a **Fork this repository**
437+
button. Nothing has gone wrong. A fork is your own copy of the repository under your own account: you
438+
make the change there, and the pull request asks the Nextcloud maintainers to take it from your copy
439+
into theirs. Click the button; it takes a moment and then opens the editor.
440+
441+
.. figure:: ../images/translations-hint-fork-required.png
442+
:alt: GitHub page reading "You need to fork this repository to propose changes", with a
443+
"Fork this repository" button
444+
445+
What an outside contributor sees instead of the editor. This is expected.
446+
447+
**You only do this once.** The fork stays on your account, so the next hint you add starts in the
448+
editor straight away.
449+
450+
If it has been a while since you last contributed, your fork will be behind the original repository.
451+
Go to your fork - ``github.com/<your-username>/<repository>`` - and look at the bar above the file
452+
list. When the fork is out of date, a line there reads *"This branch is N commits behind ..."*, with
453+
a **Sync fork** button at its right-hand end, next to **Contribute**. Use it, then **Update branch**,
454+
before you start editing, so your change is made against the current files rather than an old copy.
455+
If no such line is shown, your fork is already up to date and there is nothing to do.
456+
457+
.. figure:: ../images/translations-hint-sync-fork.png
458+
:alt: The bar above a fork's file list, reading "This branch is 12 commits behind", with
459+
Contribute and Sync fork buttons at the right
460+
461+
An out-of-date fork. The **Sync fork** button only appears while there is something to sync.
462+
463+
Once you are in the editor a banner reads *"You're making changes in a project you don't have write
464+
access to. Submitting a change will write it to a new branch in your fork ..., so you can send a pull
465+
request."* That is the expected state for an outside contributor.
466+
467+
.. figure:: ../images/translations-hint-editor-fork-banner.png
468+
:alt: The GitHub web editor with a banner explaining that changes will be written to a new
469+
branch in the contributor's fork, and a "Commit changes..." button
470+
471+
After forking: the banner names your fork, and the editor opens as normal.
472+
473+
Add the comment **on the line directly above** the translation call, in the style that matches the
474+
file type (see the examples above), and match the surrounding indentation exactly. The editor's
475+
**Tabs / width / wrap** controls, above the top-right of the text area, show what the file uses.
476+
477+
.. code-block:: php
478+
479+
// TRANSLATORS Name of the SMB/CIFS share on the server, not the verb "to share"
480+
'share' => $l->t('Share'),
481+
482+
Commit and open the pull request
483+
""""""""""""""""""""""""""""""""
484+
485+
Click **Commit changes...**. A dialog headed **Sign off and propose changes** opens, with a commit
486+
message, an extended description, and a **Sign off and propose changes** button that takes you to the
487+
pull request form. You are not asked to choose a branch: a change to a fork always goes to a new
488+
branch, which is what the pull request is opened from.
489+
490+
* Nextcloud uses `conventional commits <https://www.conventionalcommits.org/>`_, so the message needs
491+
a type and a short summary, for example ``docs: add translator comment for "None"``. Check the
492+
repository's recent history for the types it actually uses.
493+
* **Do not accept a pre-filled message without reading it.** The dialog may arrive with the message
494+
and description already written - if Copilot is enabled for your account it suggests them, and the
495+
dialog says so underneath. The suggestion describes the change accurately enough but has no type
496+
prefix, for example *"Add translator comment in NullMechanism constructor"*. Putting ``docs:`` in
497+
front of it is normally the whole fix. This is the most likely reason a first pull request fails a
498+
check.
499+
* You do **not** need to add a ``Signed-off-by`` line by hand. The dialog signs the commit off for
500+
you and shows which address it is using, which satisfies the DCO check. If you have enabled
501+
**Keep my email addresses private** in your GitHub settings, that address is your
502+
``@users.noreply.github.com`` one.
503+
504+
.. figure:: ../images/translations-hint-signoff-dialog.png
505+
:alt: The "Sign off and propose changes" dialog, with a commit message field, an extended
506+
description, and a note showing the address the commit is signed off with
507+
508+
The commit dialog, with the suggested message already corrected to a conventional commit.
509+
510+
Avoiding the automated checks, rather than fixing them
511+
""""""""""""""""""""""""""""""""""""""""""""""""""""""
512+
513+
Pull requests run linters and coding-style checks, and there is generally no way to run or fix those
514+
from the web interface. It is therefore worth avoiding a failure in the first place:
515+
516+
* Put the comment on its own line. Do not append it to an existing line of code.
517+
* Copy the indentation of the line below it, including tabs versus spaces.
518+
* Leave no trailing whitespace at the end of the comment.
519+
* Change nothing else in the file, so that the diff is the single added line.
520+
521+
If a check does fail, say so in the pull request. A maintainer can push the fix to your branch.
522+
523+
What happens next
524+
"""""""""""""""""
525+
526+
A Nextcloud maintainer will review the pull request. You do not need to request a review, add labels
527+
or assign anyone - an outside contributor cannot do those things, and it is not a sign that anything
528+
is missing from your pull request. If nothing happens for a while, a polite comment on the pull
529+
request is the right nudge.
530+
531+
You are also welcome to tell the translation community about it. Other translators hit the same
532+
ambiguous strings, and it is the easiest way to let them know a hint is on its way:
533+
534+
* the `translation chat room <https://cloud.nextcloud.com/call/xs25tz5y>`_ is open to the public and
535+
needs no account, and is the quickest way to say something
536+
* the `Translations category of the Nextcloud forum
537+
<https://help.nextcloud.com/c/translations/23>`_ keeps the note findable afterwards. Anyone can
538+
read it, but posting needs a free forum account
539+
540+
Post the link to your pull request and a sentence about the string you clarified.
541+
542+
Once it is merged, the hint still does not reach translators immediately. It reaches them when the
543+
source strings are next extracted and synchronised to Transifex, so allow for that delay before
544+
looking for it in the web interface.
545+
546+
403547
Adding translations
404548
-------------------
405549

103 KB
Loading
99.3 KB
Loading
191 KB
Loading
43.5 KB
Loading

0 commit comments

Comments
 (0)