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

Support editing arrays for language variables #6935

Closed

Conversation

afbora
Copy link
Member

@afbora afbora commented Jan 23, 2025

Description

develop test_panel_languages_en

Summary of changes

  • Now language variables also support arrays (string, array and null)

Reasoning

We talked with Nico about how we should support array language variables.

I tried structure field but gave up because it was opened with drawer (not easy to edit each entry), it had deletion issues and it did not work fully compatible with dialog.

Nico's suggestion was to show as many inputs as there are variables in the array. I implemented this. I did not implement this in the creation part because it is not clear how many variables the user will enter, so I did not do this feature for now.

My alternative suggestion is a new field suggestion for such needs for K5 or K6; entries. It is similar to structure field but much simpler. You can think of it as a text field field that can be added more than once. If we have entries field in K5 or K6, we can use entries field in the language variables part.

I did not want to add unit tests without getting a full response from you. I will add it last.

Changelog

Fixes

Breaking changes

None

Docs

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add lab and/or sandbox examples (wherever helpful)
  • Add changes & docs to release notes draft in Notion

@afbora afbora added the needs: tests 🧪 Requires missing tests label Jan 23, 2025
@afbora afbora requested a review from a team January 23, 2025 10:36
@afbora afbora self-assigned this Jan 23, 2025
@afbora afbora added the needs: discussion 🗣 Requires further discussion to proceed label Jan 23, 2025
@afbora afbora requested a review from distantnative January 23, 2025 10:40
@afbora afbora force-pushed the fix/6930-support-array-language-variables branch from 1384147 to abb5742 Compare January 23, 2025 10:49
@bastianallgeier
Copy link
Member

I was thinking about an "entries" field for a while now too and I agree that this would be a great chance to use it here.

But since we are working with a very defined set of options here, I think we could also add a toggle to switch between single value and pluralized array values.

The fields could then also get better labels. I.e.

  • "Zero"
  • "One"
  • "Many"

@distantnative
Copy link
Member

@bastianallgeier The tricky part is that our setup actually allows more then 3 options. A i18n translation might be defined for e.g. cases of 0, 1, 2, and more. Which needs 4 fields then. That's why Ahmet creates them dynamically from the number of array entries.

@bastianallgeier
Copy link
Member

Ok, but that makes sense. Then I would really just improve the labels

@afbora
Copy link
Member Author

afbora commented Jan 27, 2025

How would you like to improve labels?

@bastianallgeier
Copy link
Member

Ah, I've just seen in the translateCount method that it's not super easy. Can we maybe explain it somehow in an info box above and then do labels like this:

Count: 0
Count: 1
Count: 2

?

@distantnative
Copy link
Member

distantnative commented Jan 27, 2025

Or we do dynamic help texts as well?

This string will be used if count is 0.
This string will be used if count is 1.
This string will be used if count is 2 or more.

@afbora
Copy link
Member Author

afbora commented Jan 27, 2025

So what about labels?
Also what if 1, 2 or 4 entries have? Should be like that?

This string will be used if count is 0.
This string will be used if count is 1 or more.

This string will be used if count is 0.
This string will be used if count is 1.
This string will be used if count is 2 or more.

This string will be used if count is 0.
This string will be used if count is 1.
This string will be used if count is 2.
This string will be used if count is 3 or more.

@distantnative
Copy link
Member

Yep, I think that would be the logic.

For labels it could be similar:

Translation for 0 count
Translation for 1 count
Translation for 2+ count

@afbora afbora added the needs: delay ⏳️ Requires more time, on hold label Jan 28, 2025
@afbora
Copy link
Member Author

afbora commented Jan 30, 2025

Closing favor of #6963

@afbora afbora closed this Jan 30, 2025
@afbora afbora deleted the fix/6930-support-array-language-variables branch January 30, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: delay ⏳️ Requires more time, on hold needs: discussion 🗣 Requires further discussion to proceed needs: tests 🧪 Requires missing tests
Development

Successfully merging this pull request may close these issues.

Language view: support for i18n string as arrays (those using translateCount
3 participants