Closed jmeiss closed 2 years ago
Hi @jmeiss, thanks for sharing this! Your solution looks great to me. Would you mind sending a pull request to improve this?
Hi @seratch
At the end, I went for a completely different solution. Since I needed to translate many pages with their subpages and images, I simply duplicated the whole notion folder (aka Page) in order to not have to rebuild the folders and files structure as well as duplicate the images. I then went through each page, sent it to my updated version of your package in order to translate and translate in place each string.
Here is the code diff if you're interested in it: https://github.com/Fluicity/notion-translator/commit/4c6d82d3650afd26603a51613dcc66a726b39c1c
Once again, thanks a lot for that very helpful package 🙏
@jmeiss Thanks for sharing the details! I've checked this issue on my end and found that, as long as the image URLs are external ones, which do not expire, image blocks still work in the translation process.
I've been using this template for testing this tool. The images in the page do not expire. This is why I didn't realize the expiration of uploaded image URLs.
Your updates are awesome! I look forward to seeing the evolution on your fork 👍
Hi, why not upload and replace it with external images? I asked ChatGPT and get the code below to use cloudinary, and it works :)
const cloudinary = require('cloudinary').v2;
// Configure your Cloudinary credentials cloudinary.config({ cloud_name: 'your_cloud_name', api_key: 'your_api_key', api_secret: 'your_api_secret' });
// The URL of the image you want to fetch and upload const imageUrl = 'http://external.domain.com/path-to-image.jpg';
// Use Cloudinary's API to fetch and upload the image cloudinary.uploader.upload(imageUrl, { resource_type: "image" }, function(error, result) { if (error) { console.log('Error:', error); } else { console.log('New Image URL:', result.url); } });
First of all, thanks a lot for that very useful package, it will save us a lot of time and sweat 🙏
I just tried to use it on a page with an image but I'm getting the following error:
I tried to add a statement to read the
type === "image"
but after digging a bit, it looks like I can't copy an image since the image URL is now expirable ( https://twitter.com/notionhq/status/1463669460938760198?lang=en )Adding that block as a workaround prevent the script from crashing but I was really hopping to be able to copy the image:
From my understanding, I can't copy the image because I can't fetch then re-upload the image.
https://developers.notion.com/reference/file-object
My ticket is to: