Friday, May 31, 2013

Change The Default Text For Anything


Hey
This post is a proper hacking post. It is designed to go into the core of the Mac OS X operating system and enable you to change some of the strings that control certain parts of text on your system. For example with this post you will be able to change the new folder name, as well as various other parts of your operating system. Once you get the hang of it you will be able to hack and crack your way to a computer system the way you like it.
Before we start I must stress that a lot of things can go wrong here. If you change the strings file incorrectly, the resulting application will probably crash, or everything you see will be garbled and unreadable. Do this at your own risk. It is safe as long as you insert your brain before you start anything. As always make sure you have a back up of the file your are going to change. I will point out which files you will need to back up as we proceed.

Finder

The first step is to find the strings file. This is a file that contains all of the various bits of text and strings that programs refer to when you run them. They are also called localizable strings. This is because it will only contain the text for one language. To find this file go to /System/Library/CoreServices/Finder.app/Contents/Resources/English.lpoj. You can change the final folder to the language of your choice. In this folder you should look for Localizable.strings. This is file we will be changing. Back this file up to good location on your hard drive. Any changes you make to Localizable.strings there should be a backup.
Now copy this folder to your desktop, or anywhere you want. We are going to modify this file, then copy it back into the Finder.app folder. It is a lot easier to edit this file and then copy it back in, rather than fiddling with permissions. When you open this file you should see something similar to the image below.
The number of the left refers to a reference number for that string. For example when the program runs and wants to display a string it will load and show you that number. That is how you can have more than one language file. They copy this file and then change the corresponding text. As a result I makes it very easy to code for different languages. On the right on the string is the actual text you can change. Only change text between the speech marks (“”) and make sure the semi-colon (;) and equal sign is in the right place. We don’t want Finder crashing and you not being able to use it.
New Folder
As an introduction to how to change the strings search the left hand column for N2. This is the string that displays the text when your create a new folder. You can then change this text to something more useful.
Original: "N2" = "untitled folder";
Modified: "N2" = "New folder";
Save this file. The next step is to copy it back it. Drag and drop your file into the Finder.app folder and then authentic the file with your password. The next step is to restart the application for the new file to be loaded into memory. Normally your would close the program and start it up again. There isn’t an easy way to do that with Finder so you have to use the command line below.
killall Finder
This will kill Finder and start it back up again. If all goes well when you do a certain command your new text should appear.
Other Strings To Note
"N3" = "^0 alias";
"N4" = "^0 copy";
This is used when you make a copy of a file and make an alias. If you want to change these make sure you leave ^0 intact.
"AL1" = "Cancel";
"AL2" = "Save";
"AL3" = "Continue";
"AL4" = "OK";
"AL5" = "Authenticate";
"AL6" = "Skip";
"AL7" = "Delete";
"AL8" = "Eject";
These are used to change various dialog boxes. I would recommend you leave them alone, although you can change them if you wish.
"N150" = "Help";
"N151" = "Open";
"N152" = "Open With";
"N153" = "Move to Trash";
"N154" = "Duplicate";
"N155" = "Make Alias";
"N156" = "New Folder";
"N156.1" = "New Burn Folder";
"N156.2" = "New Smart Folder";
"N157" = "Empty Trash";
"N157.1" = "Secure Empty Trash";
"N158" = "Show Package Contents";
"N159" = "Show Inspector";
"N161" = "Always Open With";
"N162" = "Open Enclosing Folder";
"N164" = "Change Desktop Background…";
"N165" = "Get Info";
"N165.1" = "Show Inspector";
"N165.2" = "Get Summary Info";
"N167" = "Print";
"N168" = "Compress “^0”";
"N169" = "Compress ^0 Items";
These are used on the right click and File menus.
"IV6" = "1 item";
"IV8" = "No items";
"IV9" = ", ^0 free";
"IN3" = "^0 items";
These four are used to show you various pieces of information on your desktop. For example for number IV9, if you remove the “free” part of the string you can shorten the amount of text shown on your desktop when you view a hard disk. This is very useful if you have small font and you find certain pieces of text is truncated.
Sidebar
In the sidebar of Finder you can change the strings so they display something different. Instead of using Localizable.strings open LocalizableCore.strings. This contains more strings but look for the text below.

"SD5" = "DEVICES";
"SD6" = "SHARED";
"SD7" = "SEARCH FOR";
"SD8" = "PLACES";
You change these so the sidebar text for the different headers displays something different. Personally I have removed the capitalization.

Mail

Finder used the strings in the file by looking through for a number and letter. Different applications, in this case Mail, use a text string (in capitals). For example the following is an example of how the strings file works in Mail. The file is located here: /Applications/Mail.app/Contents/Resources/English.lproj
/* String shown in main window to show a message was sent/received yesterday. */
"YESTERDAY" = "Yesterday";
This file is a lot more useful to us. This is because it has a comment above the string. You have more of an idea of what the string does. Like before change the text on the right of the string and not the words in capitals.

ITunes

I like iTunes, and there is a lot of modifications for this program. This strings file is again set up slightly differently. For example you can change the sidebar names, in a similar way to Finder.
"135.011" = "LIBRARY";
"135.012" = "DEVICES";
"135.013" = "STORE";
"135.014" = "PLAYLISTS";
"135.016" = "Apple TV";
I have changed these strings so they are not capitals. The result is something like this.

Conclusion

This technique, once as you get the hang of it, is really simple. You can quickly and easily go around any application you choose and change the strings. Some things to point out. Always have a backup. Always make sure you have written the string correctly. You may notice that some program will not have a strings file. These programs are poorly written, but most newer well written programs will.
If you have any more tricks, please leave a comment below. I would love to see what strings people have found and how they have changed them.

0 comments: