feat(i18n): add qpv locale for Viossa translations
- Add qpv (pidgin viossa) as ISO-friendly locale code - Create qpv.ftl based on vp-VL.ftl for Viossa UI strings - Update LOCALE_IDS and locale loading to include qpv - Add langcode parameter to DrupalService for content filtering - Support 'en' and 'qpv' language codes for Drupal translations
This commit is contained in:
parent
68792b9cf5
commit
22636f025f
3 changed files with 43 additions and 9 deletions
|
|
@ -24,16 +24,19 @@ interface FetchOptions {
|
|||
|
||||
interface NodeListParams extends JsonApiParams {
|
||||
contentType: ContentType;
|
||||
langcode?: "en" | "qpv"; // Support English and Viossa translations
|
||||
}
|
||||
|
||||
interface NodeParams extends JsonApiParams {
|
||||
id: string;
|
||||
contentType: ContentType;
|
||||
include?: string[];
|
||||
langcode?: "en" | "qpv";
|
||||
}
|
||||
|
||||
interface TaxonomyParams {
|
||||
vocabulary: Vocabulary;
|
||||
langcode?: "en" | "qpv";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,9 +71,14 @@ export class DrupalService {
|
|||
/**
|
||||
* Build query string from JsonApiParams
|
||||
*/
|
||||
private buildQueryString(params: JsonApiParams = {}): string {
|
||||
private buildQueryString(params: JsonApiParams = {}, langcode?: string): string {
|
||||
const queryParts: string[] = [];
|
||||
|
||||
// Language filter for translated content
|
||||
if (langcode) {
|
||||
queryParts.push(`filter[langcode]=${langcode}`);
|
||||
}
|
||||
|
||||
// Include relationships
|
||||
if (params.include?.length) {
|
||||
queryParts.push(`include=${params.include.join(",")}`);
|
||||
|
|
@ -161,8 +169,8 @@ export class DrupalService {
|
|||
async getNodes<T extends DrupalNodeAttributes = DrupalNodeAttributes>(
|
||||
params: NodeListParams
|
||||
): Promise<JsonApiDocument<T>> {
|
||||
const { contentType, ...queryParams } = params;
|
||||
const queryString = this.buildQueryString(queryParams);
|
||||
const { contentType, langcode, ...queryParams } = params;
|
||||
const queryString = this.buildQueryString(queryParams, langcode);
|
||||
const url = `${this.baseUrl}/node/${contentType}${queryString}`;
|
||||
|
||||
return this.fetchJson<JsonApiDocument<T>>(url);
|
||||
|
|
@ -175,9 +183,9 @@ export class DrupalService {
|
|||
async getNode<T extends DrupalNodeAttributes = DrupalNodeAttributes>(
|
||||
params: NodeParams
|
||||
): Promise<JsonApiDocument<T>> {
|
||||
const { id, contentType, include } = params;
|
||||
const { id, contentType, include, langcode } = params;
|
||||
const queryParams: JsonApiParams = include ? { include } : {};
|
||||
const queryString = this.buildQueryString(queryParams);
|
||||
const queryString = this.buildQueryString(queryParams, langcode);
|
||||
const url = `${this.baseUrl}/node/${contentType}/${id}${queryString}`;
|
||||
|
||||
return this.fetchJson<JsonApiDocument<T>>(url);
|
||||
|
|
@ -189,8 +197,9 @@ export class DrupalService {
|
|||
async getTaxonomyTerms(
|
||||
params: TaxonomyParams
|
||||
): Promise<JsonApiDocument<DrupalTaxonomyTermAttributes>> {
|
||||
const { vocabulary } = params;
|
||||
const url = `${this.baseUrl}/taxonomy_term/${vocabulary}`;
|
||||
const { vocabulary, langcode } = params;
|
||||
const queryString = langcode ? this.buildQueryString({}, langcode) : "";
|
||||
const url = `${this.baseUrl}/taxonomy_term/${vocabulary}${queryString}`;
|
||||
|
||||
return this.fetchJson<JsonApiDocument<DrupalTaxonomyTermAttributes>>(url);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue