Hi guys,
I have set up kirby with a single language and have created articles so far, which generates article.txt per Article which is totally fine.
After adding the language config I was trying to resave those articles in the panel in a certain language. My problem here is that instead of generating for example “article.en.txt”, kirby generates a default-txt-file like “default.en.txt” and for some reason my template for Articles isn’t “article” but “default” now…
I know the docs say I would need to replace/rename those but I am wondering if there’s an easier and faster way to do so since I have more than 100 articles I would need to rename…
Help is appreciated!!
Thanks!
Kirby does not rename the files for you. I suggest you batch rename them in the file system, that is fast and reliable.
Something like this should do it. Backup your files first. I have not tested this. Assumes your on linux or Mac.
Pull terminal and CD
into your content folder. You made a backup, right?? This will recursively change the file extension.
find . -name "*.txt" -exec bash -c 'mv "$1" "${1%.txt}".en.txt' - '{}' \;
Replace .en.txt
with the language code you want to use.
Source article
If you are on a Mac, you can do it without terminal like this:
- Use search to find all files in the blog folder.
- Select all files.
- Right-click and select “rename files”
- In the dialog, select “add text” and “after filename”
- Enter .en (or whatever language code you need)
- Click OK.
- Done-
1 Like
Beat me to it, i was about to explain that as well ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=5)
1 Like
Alternatively, if you happen to be stuck on Windows, you are missing a whole bunch of commands that we on Mac’s or Linux can have fun with. You can now use these on Windows 10 Anniversary Edition or above by enabling the Ubuntu bash.
Why would you want to? Two reasons spring to mind:
Firstly, Windows does not have an SSH command built in. Now you do.
Secondly, if you work with NPM you can end up with modules installed that exceed the windows folder depth limit, meaning you cant delete them in Windows Explorer. Enabling Ubuntu bash allows you to use rimraf
command which doesnt care about depth.
The terminal command above will also work, as well as bunch of other tricks.
Your welcome ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=5)
If you use Sublime Text as your code editor, you may be interresting by this post
http://www.kubilayerdogan.net/use-sublime-text-to-bulk-rename-your-files/
Not tested so backup your files before any test ![:wink: :wink:](https://emoji.discourse-cdn.com/twitter/wink.png?v=5)
Seems there is an equivalent extension for Atom as well.
you can also manually rename them in bulk with something like antrenamer (for windows)
If the webserver runs windows, you can use a solution I have posted about a year ago:
Rename all the content files to include the language code
Yes, I am on a Mac and will try it out via terminal first.
Thanks a lot for all the quick replies ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=5)