Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

office-addin-manifest export fails when localization file is referenced #822

Open
atremel opened this issue Dec 29, 2023 · 3 comments
Open

Comments

@atremel
Copy link

atremel commented Dec 29, 2023

Prerequisites

As per the docs (https://learn.microsoft.com/en-us/office/dev/add-ins/develop/localization?tabs=jsonmanifest), manifest localization can be done like so:

"localizationInfo": {
    "defaultLanguageTag": "en",
    "additionalLanguages": [
        {
            "languageTag": "de",
            "file": "de.json"
        }
    ]
},

the file de.json is in the manifest's directory, has the correct name and the correct contents as per the docs (see above).

  • [ x ] I am running the latest version of Node and the tools
  • [ x ] I checked the documentation and found no answer
  • [ x ] I checked to make sure that this issue has not already been filed

Expected behavior

office-addin-manifest export should work. However, it fails.
This is because the translation file is not included in the manifest.zip, see code, only the main json will get zipped:

zip.addLocalFile(manifestPath, "", "manifest.json");

Current behavior

I get an error "File for languageTag de is missing from the package or path is pointed to a wrong file."

@canturan
Copy link

Is there any update on this topic.
I have the same issue. After I added the localization files, when I execute npm start to debug the add-in, I get the following error message, because the localization files are not added to the manifest.zip file.
image

@b-tosic
Copy link

b-tosic commented Feb 12, 2025

I'm facing the same issue.
It seems that local sideloading is not possible with localization files.

Is there a solution for this?

@b-tosic
Copy link

b-tosic commented Feb 12, 2025

Well, in case it is helpful to anyone, until the official fix is released this is how I made a workaround:
edit your local package file here:
\node_modules\office-addin-manifest\lib\export.js

locate function createZip and inside that function add localization file(s) zipping just below line that calls addIconFile.
Here is an example, new code is between MANUAL WORKAROUND BEGIN and MANUAL WORKAROUND END comments:

addIconFile((_b = manifest.icons) === null || _b === void 0 ? void 0 : _b.outline, manifestDir, zip);
//MANUAL WORKAROUND BEGIN

        if(manifest.localizationInfo !== undefined && 

           manifest.localizationInfo.additionalLanguages !== undefined){

            for(let localizationLang of manifest.localizationInfo.additionalLanguages){

                zip.addLocalFile(localizationLang.file, "", localizationLang.file);

            }

        }

//MANUAL WORKAROUND END

        return Promise.resolve(zip);

Now, next time you run locally (sideloading) manifest.zip will contain also localization files and it should work when switching languages in Office app.

Hopefully this helps someone...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants