You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91-74Lines changed: 91 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,50 +1,34 @@
1
1
# React AutoLocalise
2
2
3
-
This is SDK for [AutoLocalise](<[AutoLocalise](https://www.autolocalise.com)>).
3
+
This is SDK for [AutoLocalise](https://www.autolocalise.com).
4
4
5
-
A lightweight, efficient auto-translation SDK for React, React Native, and Expo applications. This SDK provides seamless integration for automatic content translation and support offline mode.
5
+
A lightweight, efficient auto-translation SDK for Reactand Next.js applications. This SDK provides seamless integration for automatic content translation with support for server-side rendering.
6
6
7
7
You don't need to prepare any translation files, just provide your API key and the SDK will handle the rest.
8
8
9
9
## Features
10
10
11
-
- 🌐 Cross-platform support (React Web, React Native, Expo)
The locale format follows the ISO 639-1 language code standard, optionally combined with an ISO 3166-1 country code:
94
+
This SDK provides comprehensive SSR support through middleware-based locale detection and server components. Here's how to implement end-to-end server-side translation:
111
95
112
-
- Language code only: 'en', 'fr', 'zh', 'ja', etc.
113
-
- Language-Region: 'en-US', 'fr-FR', 'zh-CN', 'pt-BR', etc.
96
+
### Middleware Setup
114
97
115
-
## How to get the locale
98
+
Create a middleware file to detect user's locale from request headers or URL parameters:
116
99
117
-
### React
100
+
```tsx:/src/middleware.ts
101
+
import { NextResponse } from"next/server";
102
+
importtype { NextRequest } from"next/server";
118
103
119
-
In React web applications, you can get the user's preferred locale from the browser:
<h1>{translations["Hello from Server Component"]}</h1>
151
+
<p>{translations["This component is rendered on the server side"]}</p>
152
+
</div>
153
+
);
154
+
}
150
155
```
151
156
152
-
### Expo
157
+
### SEO Considerations
153
158
154
-
In Expo, you can use the Localization API from expo-localization:
159
+
While our SDK currently supports server-side rendering of translated content, achieving full locale-specific visibility in search engine results requires additional implementation. We're working on this step by step example and welcome community contributions to:
155
160
156
-
```typescript
157
-
import*asLocalizationfrom"expo-localization";
161
+
- Implement canonical URL handling for localized content
0 commit comments