A Powershell module to easy handle i18n in SharePoint online sites.
This is a PowerShell script that generates a CSV file in a specific format. Once the CSV file is generated, it can be passed to the "ConvertFrom-SpoI18nCsv" function to produce *.resx files. The script has several parameters that allow you to customize the extraction process, such as specifying the site URL, output path, locales to translate, content types and fields pattern to include or exclude, and lists and views to include. The resulting CSV file contains the default item's DisplayName for each specified locale, which can be replaced with the translations.
- Installation process
Install-Module -Name SpoI18n;
- Software dependencies
PnP.Powershell >= 1.11.0
A useful tool to make easy i18n in Sharepoint Online.
It lets you handle i18n process, in three simple steps:
-
- Create a CSV file for a site or multiple sites
# Connect to SPO site, using PnP.Powershell
Connect-PnPOnline -interactive <url>
Get-SpoI18nCsv -outputPath "<path-to-folder>\<file name>.csv" `
-locales en-US,it-IT `
-fieldsPattern "Custom_" `
-ctGroups "CtG1","CtG2","CtGN" `
-lists @(
"List to extract 1"
"List to extract 2"
"List to extract N"
);
-
- If you have many "identical" sites, you can copy translations between them
Copy-SpoI18nCsv -src '<path-to-source-file>' `
-dest '<path-to-destination-file>' `
-locale '<locale-to-copy>' `
-localeKey '<locale-to-use-as-key>';
# Add "-replace" param if you want to replace "destination file",
# otherwise a new file will be generated with timestamp as suffix.
-
- Convert CSV file to a Resource File ("*.resx")
ConvertFrom-SpoI18nCsv -fileName "<output-file-name>" `
-outputPath "<output-folder-path>" `
-src "<file-to-convert-path>";
# By default every locales in the src file will be used to generate a Resx file,
# if you want to skip one or more locales add localesSkip param.
# Eg: "-localesToSkip en-US,it-IT"
Extract a CSV for ContentTypes, Fields, Lists and Views of a SPO site.
CSV format:
Key, [Locale1],Comment.[Locale1], [Locale2],Comment.[Locale2], ...[LocaleN],Comment.[LocaleN]
In each "Locale" column you'll find the default item's DisplayName. Replace values where needed and save the file.
Name | Description | Example |
---|---|---|
siteUrl | Site's URL, if not provided it will look for a PnPConnection and if exists it'll use it. | "https:\\.sharepoint.com\sites<sitename>" |
outputPath | Output file destination | "~/Desktop/SpoI18nCsv.csv" |
locales | List of locales, including default locale, to translate the site. | en-US, it-IT |
fieldsPattern | It allows you to restrict the Fields number to translate; Don't use wildcards, they will be added automatically at the begin and the end of pattern. |
"CUSTOM_" will be used as "*CUSTOM_*" |
ctGroups | It allows you to restrict the ContentTypes number to translate filtering them by Group. |
MyCustomCT, AnotherCtGroup |
noCtGRoups | It allows you to exclude ContentTypes; | |
lists | It allows you to specify wich lists you want to translate. | |
includeListViews | If set, all views in each list will be included in the file |
It converts a CSV file to "*.resx" files that fulfills SPO site requirements.
Name | Description |
---|---|
fileName | Output file prefix name. |
outputPath | Destination folder path. |
src | Path of the CSV file. |
It converts a CSV file to "*.resx" files that fulfills SPO site requirements.
Name | Description |
---|---|
src | Path of the source file. |
dest | Path of the destination file. |
locale | Locale to copy. "Eg: it-IT" |
localeKey | Default Locale. Used as a key, it helps to find match. "Eg: en-US" |
replace | If set, replace the destination file; Otherwise a new file will be created, in the same folder, named: "<DestinationNameFile>_<DateFormat[yyyMMddHHmm]>.csv" |