Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3dc1e8d3
Commit
3dc1e8d3
authored
Nov 26, 2019
by
Paul Gascou-Vaillancourt
Committed by
Russell Dickenson
Nov 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document sprintf usage
parent
1009293e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
doc/development/i18n/externalization.md
doc/development/i18n/externalization.md
+39
-0
No files found.
doc/development/i18n/externalization.md
View file @
3dc1e8d3
...
...
@@ -311,6 +311,45 @@ Developer documentation][mdn].
[
mdn
]:
https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_content_best_practices#Splitting
##### Vue components interpolation
When translating UI text in Vue components, you might want to include child components inside
the translation string.
You could not use a JavaScript-only solution to render the translation,
because Vue would not be aware of the child components and would render them as plain text.
For this use case, you should use the
`gl-sprintf`
component which is maintained
in
**GitLab UI**
.
The
`gl-sprintf`
component accepts a
`message`
property, which is the translatable string,
and it exposes a named slot for every placeholder in the string, which lets you include Vue
components easily.
Assume you want to print the translatable string
`Pipeline %{pipelineId} triggered %{timeago} by %{author}`
. To replace the
`%{timeago}`
and
`%{author}`
placeholders with Vue components, here's how you would do that with
`gl-sprintf`
:
```
html
<template>
<div>
<gl-sprintf
:message=
"__('Pipeline %{pipelineId} triggered %{timeago} by %{author}')"
>
<template
#pipelineId
>
{{ pipeline.id }}
</template>
<template
#timeago
>
<timeago
:time=
"pipeline.triggerTime"
/>
</template>
<template
#author
>
<gl-avatar-labeled
:src=
"pipeline.triggeredBy.avatarPath"
:label=
"pipeline.triggeredBy.name"
/>
</template>
</gl-sprintf>
</div>
</template>
```
For more information, see the
[
`gl-sprintf`
](
https://gitlab-org.gitlab.io/gitlab-ui/?path=/story/base-sprintf--default
)
documentation.
## Updating the PO files with the new content
Now that the new content is marked for translation, we need to update
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment