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

Internationalize styled strings #1285

Open
PIG208 opened this issue Jan 15, 2025 · 1 comment
Open

Internationalize styled strings #1285

PIG208 opened this issue Jan 15, 2025 · 1 comment
Labels
a-i18n Translation, localization, internationalization

Comments

@PIG208
Copy link
Member

PIG208 commented Jan 15, 2025

For strings like '${mention(sender!, silent: true)} ${inlineLink('said', url)}: ' (the beginning of a quote-and-reply text), where part of it is styled with markdown syntax, or strings like

    return TextSpan(children: [
      TextSpan(text: "(unimplemented: text «", style: errorStyle),
      TextSpan(text: htmlNode.text, style: errorCodeStyle),
      TextSpan(text: "»)", style: errorStyle),
    ]);

where the string is fragmented with TextStyle's, expressing them with the regular placeholders is challenging.

For the quote-and-reply string, we could define a string "{user} [said]({link}): ", but that requires the translators to write valid Markdown. We want something like {user} <z>said</z>:, where only said is translatable. In zulip-mobile, we have:

          text={{
            text: 'Suggestion: <z-link>{suggestedServerUrl}</z-link>',
            values: {
              suggestedServerUrl: suggestion,
              'z-link': chunks => (
                <ZulipText
                  inheritFontSize
                  style={styles.suggestionTextLink}
                  onPress={() => handlePressSuggestion(suggestion)}
                >
                  {chunks}
                </ZulipText>
              ),
            },
          }}

(See #1148 (comment))

To resolve this, we need to search for a similar API.

For quote-and-reply specifically, we want to translate the string using the realm's locale setting, not the user's.

This is a follow-up to:

@PIG208 PIG208 added the a-i18n Translation, localization, internationalization label Jan 15, 2025
@PIG208 PIG208 added this to the M7: Future milestone Jan 15, 2025
@gnprice gnprice modified the milestones: M7: Future, M6: Post-launch Jan 16, 2025
@PIG208
Copy link
Member Author

PIG208 commented Jan 29, 2025

Another use case for this is the hint text for sending to general chat, which can be displayed as:

Message #channel_name > general chat

This also requires only part of the message to be stylized, and the current string does not support that:

  "composeBoxChannelContentHint": "Message #{channel} > {topic}",
  "@composeBoxChannelContentHint": {
    "description": "Hint text for content input when sending a message to a channel",
    "placeholders": {
      "channel": {"type": "String", "example": "channel name"},
      "topic": {"type": "String", "example": "topic name"}
    }
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-i18n Translation, localization, internationalization
Projects
Status: No status
Development

No branches or pull requests

2 participants