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 for .xcstrings catalog #6048

Open
danieleformichelli opened this issue Mar 7, 2024 · 15 comments · May be fixed by #6296
Open

Support for .xcstrings catalog #6048

danieleformichelli opened this issue Mar 7, 2024 · 15 comments · May be fixed by #6296
Assignees
Labels
bounty Resolving this issue is rewarded with a bounty: https://github.com/tuist/tuist/discussions/4982 type:need/problem Report needs or problems you came across that are not bugs

Comments

@danieleformichelli
Copy link
Collaborator

What problem or need do you have?

They were added in Xcode 15, see #5221 (comment)

Potential solution

No response

macOS version

14.4

Tuist version

4.5.0

Xcode version

15.3

@danieleformichelli danieleformichelli added the type:need/problem Report needs or problems you came across that are not bugs label Mar 7, 2024
@fortmarek fortmarek added the bounty Resolving this issue is rewarded with a bounty: https://github.com/tuist/tuist/discussions/4982 label Mar 13, 2024
@leszko11 leszko11 self-assigned this Mar 13, 2024
@leszko11
Copy link
Collaborator

I'll take a look 🫡

@muukii
Copy link
Sponsor

muukii commented Mar 13, 2024

what's the problem actually? Xcode will produce strings or stringsdict automatically if we put a xcstrings.

@leszko11
Copy link
Collaborator

Hey @muukii 👋🏼
Are you sure about that? I have never used strings catalogs, but after a quick test on ios_app_with_frameworks_and_resources I see that whenever I migrate .stringsto a strings catalog, it doesn’t exist in a project anymore.
I think the point of this issue is to include strings catalog file in a generated workspace, because now it’s not included after generation.
However, swiftgen does not support strings catalog yet according to this issue. What should we do about it?

@muukii
Copy link
Sponsor

muukii commented Mar 14, 2024

In my case, using different name to Localizable because I still have classic style strings file.
Specify table name as StringCatalog to load. Not sure it's making some effects.

CleanShot 2024-03-14 at 13 06 23@2x
CleanShot 2024-03-14 at 13 07 34@2x

@leszko11
Copy link
Collaborator

Yes, that's the possible solution, but in the context of tuist capabilities, it looks a bit like a workaround to hold both of these. I think

Just out of curiosity, are StringCatalog.strings and StringCatalog.xcstrings update each other, or if you want to add a new key, you need add it in both files?

@leszko11
Copy link
Collaborator

A little update on this one.

As I mentioned before SwiftGen does not support .xcstrings files yet.
I've tried to implement the solution mentioned here, however, flow .xcstrings -> .strings -> .swift does not fit into current resource synthesizer generator, because it requires running it twice. In addition, it doesn't support plurals(.stringsdict)

IMHO best solution would be to write custom .stencil supporting .xcstrings files in SwiftGen, and then extend TuistGenerator with a .xcstrings support. I can start to work on it, but I'm not an expert in writing stencils(yet 🤞)

@pepicrft
Copy link
Contributor

IMHO best solution would be to write custom .stencil supporting .xcstrings files in SwiftGen, and then extend TuistGenerator with a .xcstrings support. I can start to work on it, but I'm not an expert in writing stencils(yet 🤞)

@leszko11 is there any way we can support you in making this happen?

@leszko11
Copy link
Collaborator

@pepicrft It's in progress. I know it's going slow, but so far I've implemented all the setup required to generate .swift file from .xcstring and started to write a stencil template. I'm trying to be as close as possible to the strings asset file generated from .strings.
Aiming to complete it end of this week

@fortmarek
Copy link
Member

Amazing, thanks for the update 🙌 Let us know if you need anything from us 🙂 Happy to take a look at some early draft if you want to align on the direction of the PR

@leszko11 leszko11 linked a pull request May 19, 2024 that will close this issue
6 tasks
@leszko11
Copy link
Collaborator

I'm stuck 😔

.xcstring file under the hood is a .json file, so it needs swiftgen's JSON parser to process the file. Not using strings parser means that we're losing an access to a types property which holds a list of arguments used in translation. Without it, I have no clue, how to do it.

I've found this tool, which basically uses a strings parser to process .xcstring file and produce synthesised resources

@pepicrft
Copy link
Contributor

@leszko11 it seems that you'll have to contribute a new parser to SwiftGen that might reuse logic from the parsers that you mentioned (the JSON and the Strings). I'm not entirely familiar with the SwiftGen codebase, but it seems that those parsers can be of good reference.

@leszko11
Copy link
Collaborator

@pepicrft Yep, I think that would be the best solution. I'll start a conversation in corresponding issue

@leszko11
Copy link
Collaborator

SwiftGen/SwiftGen#1124

👀

@pepicrft
Copy link
Contributor

Niiiice! SwiftGen users will be very excited about that contribution. Thanks for making it happen @leszko11

@NiklasOemler
Copy link

Commenting to stay informed about this topic.
Can't wait to migrate to string catalogs when youre done and it's available in a new tuist version! 🎉

Greetings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty Resolving this issue is rewarded with a bounty: https://github.com/tuist/tuist/discussions/4982 type:need/problem Report needs or problems you came across that are not bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants