Skip to content

Commit

Permalink
AG-12106 Fix localisation related example generation
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlandsman committed Jul 4, 2024
1 parent f5e3f53 commit 75d71b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ function addPackageImports(
addBindingImports(bImports, imports, true, true);
}

const localeImport = findLocaleImport(bindings.imports);
if (localeImport) {
imports.push(`import { ${localeImport.imports[0]} } from '@ag-grid-community/locale';`);
}

return imports;
}

Expand All @@ -148,11 +153,6 @@ function getImports(
imports.push("import { HttpClient, HttpClientModule } from '@angular/common/http';");
}

const localeImport = findLocaleImport(bindings.imports);
if (localeImport) {
imports.push(`import { ${localeImport.imports[0]} } from '@ag-grid-community/locale';`);
}

if (importType === 'packages') {
addPackageImports(imports, bindings, exampleConfig, allStylesheets);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExampleConfig, ImportType, ParsedBindings } from '../types';
import {
addBindingImports,
addGenericInterfaceImport,
addGenericInterfaceImport, findLocaleImport,
getIntegratedDarkModeCode,
removeModuleRegistration,
} from './parser-utils';
Expand Down Expand Up @@ -80,11 +80,20 @@ function getPackageImports(bindings: ParsedBindings): string[] {
}

function getImports(bindings: ParsedBindings, importType: ImportType): string[] {
const imports = [];

const localeImport = findLocaleImport(bindings.imports);
if (localeImport) {
imports.push(`import { ${localeImport.imports[0]} } from '@ag-grid-community/locale';`);
}

if (importType === 'packages') {
return getPackageImports(bindings);
imports.push(...getPackageImports(bindings));
} else {
return getModuleImports(bindings);
imports.push(...getModuleImports(bindings));
}

return imports;
}

export function vanillaToTypescript(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ export function getInterfaceFileContents(tsBindings: ParsedBindings, currentFile
}

export function findLocaleImport(bindingImports) {
return bindingImports.find((bindingImport) => bindingImport.module.includes('ag-grid-local'));
return bindingImports.find((bindingImport) => bindingImport.module.includes('@ag-grid-community/locale'));
}

function getGenericInterface(tData) {
Expand Down

0 comments on commit 75d71b5

Please sign in to comment.