Apostrophe 2 v3.3.0 Release Notes
Release Date: 2021-08-30 // over 2 years ago-
๐ Fixes
- โ Addresses the page jump when using the in-context undo/redo feature. The page will immediately return users to their origin scroll position after the content refreshes.
- Resolves slug-related bug when switching between images in the archived view of the media manager. The slug field was not taking into account the double slug prefix case.
- ๐ Fixes migration task crash when parking new page. Thanks to Miro Yovchev for this fix.
- ๐ Fixes incorrect month name in
AposCellDate
, which can be optionally used in manage views of pieces. Thanks to Miro Yovchev for this fix.
โ Adds
- ๐ This version achieves localization (l10n) through a rich set of internationalization (i18n) features. For more information, see the documentation.
- ๐ There is support for both static string localization and dynamic content localization.
- ๐ง The home page, other parked pages, and the global document are automatically replicated to all configured locales at startup. Parked properties are refreshed if needed. Other pages and pieces are replicated if and when an editor chooses to do so.
- An API route has been added for voluntary replication, i.e. when deciding a document should exist in a second locale, or desiring to overwrite the current draft contents in locale
B
with the draft contents of localeA
. - ๐ง Locales can specify
prefix
andhostname
options, which are automatically recognized by middleware that removes the prefix dynamically where appropriate and setsreq.locale
. In 3.x this works more like the global siteprefix
option. This is a departure from 2.x which stored the prefix directly in the slug, creating maintenance issues. - ๐ Locales are stateless: they are never recorded in the session. This eliminates many avenues for bugs and bad SEO. However, this also means the developer must fully distinguish them from the beginning via either
prefix
orhostname
. A helpful error message is displayed if this is not the case. - ๐ง Switching locales preserves the user's editing session even if on separate hostnames. To enable this, if any locales have hostnames, all configured locales must have hostnames and/or baseUrl must be set for those that don't.
- ๐ An API route has been added to discover the locales in which a document exists. This provides basic information only for performance (it does not report
title
or_url
). - 0๏ธโฃ Editors can "localize" documents, copying draft content from one locale to another to create a corresponding document in a different locale. For convenience related documents, such as images and other pieces directly referenced by the document's structure, can be localized at the same time. Developers can opt out of this mechanism for a piece type entirely, check the box by default for that type, or leave it as an "opt-in" choice.
- 0๏ธโฃ The
@apostrophecms/i18n
module now usesi18next
to implement static localization. All phrases in the Vue-based admin UI are passed throughi18next
viathis.$t
, andi18next
is also available viareq.t()
in routes and__t()
in templates. Apostrophe's own admin UI phrases are in theapostrophe
namespace for a clean separation. An array of locale codes, such asen
orfr
oren-au
, can be specified using thelocales
option to the@apostrophecms/i18n
module. The first locale is the default, unless thedefaultLocale
option is set. If no locales are set, the locale defaults toen
. Thei18next-http-middleware
locale guesser is installed and will select an available locale if possible, otherwise it will fall back to the default. - ๐ป In the admin UI,
v-tooltip
has been extended asv-apos-tooltip
, which passes phrases throughi18next
. - Developers can link to alternate locales by iterating over
data.localizations
in any page template. Each element always haslocale
,label
andhomePageUrl
properties. Each element also has anavailable
property (if true, the current context document is available in that locale),title
and a small number of other document properties are populated, and_url
redirects to the context document in that locale. The current locale is marked withcurrent: true
. - To facilitate adding interpolated values to phrases that are passed as a single value through many layers of code, the
this.$t
helper provided in Vue also accepts an object argument with akey
property. Additional properties may be used for interpolation. i18next
localization JSON files can be added to thei18n
subdirectory of any module, as long as itsi18n
option is set. Thei18n
object may specifyns
to give ani18next
namespace, otherwise phrases are in the default namespace, used when no namespace is specified with a:
in ani18next
call. The default namespace is yours for use at project level. Multiple modules may contribute to the same namespace.- If
APOS_DEBUG_I18N=1
is set in the environment, thei18next
debug flag is activated. For server-side translations, i.e.req.t()
and__t()
, debugging output will appear on the server console. For browser-side translations in the Vue admin UI, debugging output will appear in the browser console. - ๐ If
APOS_SHOW_I18N=1
is set in the environment, all phrases passed throughi18next
are visually marked, to make it easier to find those that didn't go throughi18next
. This does not mean translations actually exist in the JSON files. For that, review the output ofAPOS_DEBUG_I18N=1
. - There is a locale switcher for editors.
- There is a backend route to accept a new locale on switch.
- ๐ฏ A
req.clone(properties)
method is now available. This creates a clone of thereq
object, optionally passing in an object of properties to be set. The use ofreq.clone
ensures the new object supportsreq.get
and other methods of a truereq
object. This technique is mainly used to obtain a new request object with the same privileges but a different mode or locale, i.e.mode: 'published'
. - Fallback wrappers are provided for the
req.__()
,res.__()
and__()
localization helpers, which were never official or documented in 3.x but may be in use in projects ported from 2.x. These wrappers do not localize but do output the input they are given along with a developer warning. You should migrate them to usereq.t()
(in server-side javascript) or__t()
(Nunjucks templates).
๐ Changes
- ๐ Bolsters the CSS that backs Apostrophe UI's typography to help prevent unintended style leaks at project-level code.
- โ Removes the 2.x series changelog entries. They can be found in the 2.0 branch in Github.