Skip to content

Add joinSentences() to join using sentenceSeparator #1266

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

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

Conversation

matthew-white
Copy link
Member

This PR adds a function named joinSentences() to join two separately translated sentences. In English, there should be a space between the two sentences, but in Japanese and Chinese, there shouldn't be. Often when there are multiple sentences, they are included in the same i18n message. In that case, joinSentences() isn't needed. It's only useful when combining separate messages.

Components already have an alternative to joinSentences() in the SentenceSeparator component. They also have access to the sentenceSeparator computed ref via the useI18nUtils() composable. However, we need a way for non-component code to do something similar. I also think joinSentences() may be useful even in component code in certain situations.

I've added two versions of joinSentences(). One is returned by useI18nUtils() with the rest of our i18n utility functions. The other can be used outside component code and doesn't need the composable. The one returned by useI18nUtils() doesn't need to be passed i18n because it knows it automatically. I think we may want to follow a similar pattern for our other i18n utility functions: return one version from useI18nUtils() that doesn't require i18n (this is what we do today), but then make another version available that does take i18n and can be used outside component code.

The primary motivation for this change is getodk/central#1030. There are some new toast messages where we want to be able to join separately translated sentences.

What has been done to verify that this works as intended?

New tests.

Before submitting this PR, please make sure you have:

  • run npm run test and npm run lint and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

@matthew-white matthew-white requested a review from ktuite May 19, 2025 03:31
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