Skip to content

Commit

Permalink
docs(guide): update available strategies section in strategy.md
Browse files Browse the repository at this point in the history
Enhance the clarity of the "Available Strategies" section by adding
subheadings and an important note regarding the `no_prefix` strategy.
This note emphasizes the limitations of the `no_prefix` strategy with
standard routing and its compatibility with slug-based approaches.
  • Loading branch information
s00d committed Jan 15, 2025
1 parent 99ac148 commit cdb44e0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions docs/guide/strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The `strategy` option defines how locale prefixes should be managed across your
**Type**: `string`
**Default**: `prefix_and_default`

**Available Strategies**:
## Available Strategies:

### 🛑 **no_prefix**

Expand All @@ -23,6 +23,8 @@ This strategy ensures that no locale prefix is added to your routes. Instead of
- **Locale Detection**: The locale is detected based on the user's browser language or cookies, and it is changed without altering the URL.
- **Restrictions**: This strategy does not support features like Custom paths or Ignore routes.

**Important Note**: The no_prefix strategy works only with standard routing. Any functionality tied to route generation (e.g., custom paths, dynamic route matching) can only work with other strategies. To achieve similar functionality with the no_prefix strategy, you must use a slug-based approach (e.g., `[...slug].vue`).

**Use Case**: Ideal when you want a cleaner URL structure and are relying on automatic language detection rather than explicit locale identifiers in the URL.

```typescript
Expand All @@ -35,8 +37,6 @@ i18n: {
- `/about` (for any language, e.g., `en`, `ru`, `fr`, etc.)
- `/contact` (for any language)

---

### 🚧 **prefix_except_default**

With this strategy, all of your routes will include a locale prefix, except for the default language. For the default language, the route will appear without any prefix.
Expand All @@ -57,8 +57,6 @@ i18n: {
- `/ru/about` (for Russian)
- `/fr/about` (for French)

---

### 🌍 **prefix**

This strategy ensures that every route in your application will include a locale prefix, regardless of the language. It standardizes the URL structure across all languages.
Expand All @@ -79,8 +77,6 @@ i18n: {
- `/ru/about` (for Russian)
- `/fr/about` (for French)

---

### 🔄 **prefix_and_default**

This strategy combines both the `prefix` and `prefix_except_default` behaviors. It ensures that all languages have a locale prefix in their URLs, but the default language also has a non-prefixed URL version available. When the `detectBrowserLanguage` feature is enabled, the prefixed version of the default language will be preferred.
Expand All @@ -102,8 +98,6 @@ i18n: {
- `/ru/about` (for Russian)
- `/fr/about` (for French)

---

## 📝 Conclusion

The new `strategy` option, introduced in version 1.50.0, provides more flexibility and control over how locale prefixes are handled in your application. Whether you need a clean, non-prefixed URL structure, or prefer to add locale prefixes for all or some languages, the available strategies allow you to customize your URL structure to fit your needs.
Expand Down

0 comments on commit cdb44e0

Please sign in to comment.