Closed omar2205 closed 1 year ago
What are you trying to achive?
Do you want to use typesafe-i18n
or the inlang SDK?
I'm trying to use typesafe-i18n
plugin with Inlang.
So I can't use inlang-plugin-typesafe-i18n
with the SDK?
Yes you can, but it does not make much sense in my opinion. typesafe-i18n
is primarly a library and if you use the inlang SDK, you will not use it as a library anymore. Just for storing translations in a TypeScript
file.
typesafe-i18n
has features that are currently not available in ìnlang
. Therefore the plugin has also some limitations.
It seems you are using an older version of @inlang/sdk-js
that does not include the link to the docs in the error message. You need to add the sdkPlugin
in order to be able to use the inlang SDK: https://inlang.com/documentation/sdk/configuration
Wait, how do you use this with inlang? Because like @omar2205 I followed the getting started guide and I'm getting the same sdk missing error. Can you create a simple repo of brand new Sveltekit project and set this up?
please share your inlang.config.js
/**
* @type {import("@inlang/core/config").DefineConfig}
*/
export async function defineConfig(env) {
const { default: sdkPlugin } = await env.$import(
'https://cdn.jsdelivr.net/npm/@inlang/sdk-js-plugin@0.4.4/dist/index.js'
);
// initialize the plugin
const { default: typesafeI18nPlugin } = await env.$import(
'https://cdn.jsdelivr.net/gh/ivanhofer/inlang-plugin-typesafe-i18n@2.3/dist/index.js'
);
return {
referenceLanguage: "en",
plugins: [
typesafeI18nPlugin(),
sdkPlugin({
languageNegotiation: {
strategies: [{ type: 'localStorage' }]
},
resources: {
cache: 'Build-time'
}
})
]
};
}
Looks correct. What is not working? What error do you get?
When I run npm dev
I get the same error as above:
Yo [Error]: The `sdk` property is missing in your `inlang.config.js` file.`. Make sure to use the `sdkPlugin` in your `inlang.config.js` file.
What version of the SDK have you installed?
You probably haven't read the full error message:
Vs [Error]: Failed to setup plugin 'inlang.sdk-js':
[
{
"received": "Build-time",
"code": "invalid_literal",
"expected": "build-time",
"path": [
"resources",
"cache"
],
"message": "Invalid literal value, expected \"build-time\""
}
]
remove those lines and it should work:
resources: {
cache: 'Build-time'
}
There is a typo in the docs and Build-time
should actually be build-time
and therefore the setup fails. I have fixed the documentation and it should be live in a couple of minutes.
"@inlang/core": "^0.8.3",
"@inlang/sdk-js": "^0.4.4",
yeah build-time
fixed it
build-time
fixed it for me, too. I don't have any "type safety" tho.
That's a well known issue with url imports https://github.com/inlang/inlang/issues/689
OK, thanks!
I meant in the i
function
I meant in the i
function, I don't have any hints.
This is not implemented at the moment. I have created an issue where you can subscribe to: https://github.com/inlang/inlang/issues/754
@sudo-sand FYI as Ivan said though, you shouldn't use sdkPlugin
and the typesafe-i18n-plugin
at the same time. Both plugins provide an i18n lib. You only need one.
We are updating the communication this week. If you can explain where the confusion is coming from, we can improve the docs right away :)
@samuelstroschein I thought typesafe-i18n-plugin
is an extra plugin to be used. Like JSON reader.
Because its here https://github.com/inlang/ecosystem#resources
You're saying I don't have to use typesafe-i18n-plugin
? I just follow this guide https://inlang.com/documentation/sdk/sveltekit?
That guide tell me how to set up the translations files.
@sudo-sand yes, you can use both, but it does not make that much sense. The typesafe-i18n-plugin
is primarly meant for already existing projects that use typesafe-i18n
as a library but want to use the inlang editor to update translations.
If you want to store translations in a .json
file you can use the json-plugin
.
I followed both the getting started guides and used the
inlang.config.js
in this repo. It spat a lot of minified JS, and this: