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

String template is not able to generate a function with a string parameter and a plural int #1089

Open
Velin92 opened this issue Nov 16, 2023 · 2 comments

Comments

@Velin92
Copy link

Velin92 commented Nov 16, 2023

Hello I am using the structured-swift5 strings template in my project, and when I try to generate the function for this string:

<key>a11y_read_receipts_multiple_with_others</key>
	<dict>
		<key>NSStringLocalizedFormatKey</key>
		<string>%#@COUNT@</string>
		<key>COUNT</key>
		<dict>
			<key>NSStringFormatSpecTypeKey</key>
			<string>NSStringPluralRuleType</string>
			<key>NSStringFormatValueTypeKey</key>
			<string>d</string>
			<key>one</key>
			<string>Read by %1$@ and %2$d other</string>
			<key>other</key>
			<string>Read by %1$@ and %2$d others</string>
		</dict>
	</dict>

Which contains both a string parameter and a plural parameter, swiftgen generates this:

  /// Plural format key: "%#@COUNT@"
  public static func a11yReadReceiptsMultipleWithOthers(_ p1: Int) -> String {
    return L10n.tr("Localizable", "a11y_read_receipts_multiple_with_others", p1, fallback: "Plural format key: \"%#@COUNT@\"")
  }

Which is missing the parameter for the string, and only including the parameter for the plural.
Howeve if I use the internal function directly like this:
L10n.tr("Localizable", "a11y_read_receipts_multiple_with_others", list, timelineItem.properties.orderedReadReceipts.count)
Everything works as intended, so the issue is that both the signature and the internal implementations are generated incorrectly and are missing the string parameter.

NOTE: this dict has been gerated with the use of localazy CLI

@adamrushy
Copy link

Hey, @Velin92 did you get any closer to resolving this? We are experiencing the same issues here

@Velin92
Copy link
Author

Velin92 commented Feb 6, 2024

Sadly not. I had to resolve to use the general function that I wrote down in the description.

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

No branches or pull requests

2 participants