10up / headstartwp

Build a headless website fast with WordPress, the world’s most popular CMS, and Next.js, the most popular React framework. A free and open source solution by the experts at 10up.
https://headstartwp.10up.com
153 stars 17 forks source link

How to get the translation strings from polylang #776

Closed Knskan3 closed 1 month ago

Knskan3 commented 2 months ago

Describe your question

During the implementation of the site, we might need to define string translations to be used in the template. How can we manage and GET the translation strings? I don't see any hook for this. Thanks

Code of Conduct

nicholasio commented 2 months ago

The framework doesn't have a native way to fetch polylang strings, what you could do is extend the app endpoint and include the polylang stirngs on the WP side via this filter

Then, if you are using TypeScript I'd recommend doing this: https://headstartwp.10up.com/docs/learn/data-fetching/creating-your-own-custom-hooks/#creating-your-own-appsettings-hook

Knskan3 commented 1 month ago

I'll give it a try thanks 👍