Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Export description as comment for Android #2472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vaclavsauer
Copy link

@vaclavsauer vaclavsauer commented Sep 19, 2024

Implementation of #2391

I'm not sure if tests are OK. A lot of them failed because there is a difference in line endings on windows.

"I am not just a percent {name} % sign!",
keyName = "percent and placeholders",
text = "I am not just a percent {name} % sign!",
description = "This is a description",
Copy link
Author

@vaclavsauer vaclavsauer Sep 19, 2024

Choose a reason for hiding this comment

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

had to do this this way insted of

{
  key.description = "Description"
}

Is it OK?

See additional change in ExportTranslationView

@@ -23,8 +23,9 @@ class AndroidXmlFileExporterTest {
|<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
| <string name="key1">Ahoj! I%d, %s, %e, %f</string>
| <string name="percent_no_placeholders">I am just a percent \% sign!</string>
| <string name="percent_and_paceholders">I am not just a percent %s %% sign!</string>
| <string name="percent_and_paceholders_and_tags"><![CDATA[I am not just a percent <b>%s</b> %% sign!]]></string>
| <!--This is a description-->
Copy link
Contributor

Choose a reason for hiding this comment

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

You're testing only the plain string comment, but not plural and string array item.

@@ -25,6 +21,10 @@ class AndroidStringsXmlFileWriter(private val model: AndroidStringsXmlModel) {
private fun Element.addToElement(unit: Map.Entry<String, AndroidXmlNode>) {
when (val node = unit.value) {
is StringUnit -> {
val comment = node.comment
if (!comment.isNullOrEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It wold be great to Create a private extension function Element.comment, which will add the comment only if it's not null to remove the deduplicate the duplicated null checking logic.

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.

2 participants