apostrophecms / apostrophe

A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
https://apostrophecms.com
Other
4.36k stars 590 forks source link

localization api returns default locale #3860

Closed iampeternguyen closed 1 year ago

iampeternguyen commented 2 years ago

To Reproduce

Step by step instructions to reproduce the behavior:

  1. Localize page content into 2 or more languges
  2. Request a page with apos-locale set to defined locale (ex: /api/v1/@apostrophecms/page/pageid?apikey=secret&apos-locale=en)
  3. See that results are always in default locale

Expected behavior

Should return results in requested locale

Describe the bug

apos-locale query param isn't working. when i make a request for data with apos-locale set, the default language is returned.

Details

The only way I've been able to request localize content is to add locale:published to the id of my request. (ex: /api/v1/@apostrophecms/page/pageid:en:published?apikey=secret), but even when i do, the _url for a page is still the default one not the localized one.

For example my english homepage should be /en but it's /de here. image image

BoDonkey commented 2 years ago

Hi @iampeternguyen Thank you for bringing this to our attention! This is actually a bug in our documentation rather than in Apostrophe. When Apostrophe entered into beta, there was a decision to convert all the query parameters to camelCase to maintain consistency with the query builders. Those changes never made it into our documentation. We plan to remedy this quickly by updating our documentation. In the meantime, you can convert your requests to /api/v1/@apostrophecms/page/pageid?apikey=secret&aposLocale=en&aposMode=published, where the pageid is the expected one without appending the locale:published. If you need the rendered areas use renderAreas=true not render-areas=true. Sorry for the trouble and thanks again.

NOTE: leaving this open for others to find until the documentation has been updated.

iampeternguyen commented 2 years ago

ah perfect! this does exactly what i wanted.