I'm rather new to Objective C (I'm using Xcode, if it's relevant). I tried to find an answer to this, but couldn't find anywhere...
My question is: Is there a possible way to change a variable name in the Localizable.strings file, so that it would change in the entire app?
I do not want to use the "search and replace" option, since if there are more instances of that string which are not this variable's name, they would change too (which is something I'm interested to avoid).
Basically I'm interested in finding the parallel function to java's "refactor", while using eclipse. Thanks to all helpers!
No, not possible to do it automatically. At least not in XCode - maybe AppCode can offer something, but I doubt it. Localizable.strings is not code - it's a text file which contains key-value pairs. Thus there are no real references to keys in your code, just same string values in your code and in the file.
Related
I want to localize a shortcut and have come across this API SHSetLocalizedName() which takes a path to an executable and a resource ID. However, I want to use a string instead. It looks like it just writes to desktop.ini:
[LocalizedFileNames]
Test.lnk=#program.exe,-101
I played with it manually and I can just do this:
[LocalizedFileNames]
Test.lnk=Localized Name of Test Shortcut
Does anyone know a programmatic way of doing this? I really don't want to write to desktop.ini myself.
Thanks.
A hard coded string is the opposite of localization!
The point of SHSetLocalizedName is to have various parts of the start menu and some special folders (My documents etc.) display in a language that matches the users current UI language. To do this the string has to be a resource in a PE file so that the magic of multiple versions of a resource in different languages can work.
If you always want a specific name you can just rename the file. If you can't do that (you don't have write access or you are trying to trick the user) then perhaps this is not something you should programmatically be doing?
SHGetSetFolderCustomSettings knows how to change some values in desktop.ini but this string is not one of them. I believe using WritePrivateProfileString is the only solution...
I have an issue, I wouldn't say it's a problem at the moment, but I can see how it could turn into one in the future.
I'm following some tutorials from Ruby, so I have a folder with a bunch of different files. In one of them, I was studying Hashes, and they showed that I could name its keys like :key. No problem so far.
The issue came when I was studying Classes and I had to declare the class attributes, IntelliSense (I guess, maybe it is another extension) would recommend code completion with the keys I declared in that Hashes ruby file.
So I tested some stuff and:
It wasn't unique to that file (of course).
It's not just in hashes, it will recommend any type of :attribute I create. Whether it is classes or hashes (which is what I have tried so far), it doesn't matter.
It isn't unique to that folder. If I have the files in different folders, with different depths let's say, it will still appear.
The only way I found to get rid of that was to erase the file, and that's no solution at all.
I guess my precise question is: How can I disable that code completion characteristic?
You can ignore file or folder in code completion by adding it to files.watcherExclude setting.
Files must be closed in editor: if ignored file is open, it will still be used for autocomplete.
While in a folder with lots of files, one can select many and rename only one. This one will get the name NewName (1) and the rest will follow as NewName (2) etc..
Is there a way to use this algorithm?
I mostly interested in using WinApi methods in general. It is easy to implement this specific algorithm. I don't know how to dig into explorer.exe and see what method it uses but probably it would be something reusable.
I mostly use c# but any language example would be accepted.
Not with a single function call, no. But you can loop through the files one at a time using SHFileOperation() with the FOF_RENAMEONCOLLISION flag to rename each file to the same target filename so Windows will generate its own unique filenames.
As pointed out by Remy Lebeau I came up with the official way to do it.
IFileOperation::RenameItems
Declares a set of items that are to be given a new display name.
All items are given the same name.
...
If more than one of the items in the collection at pUnkItems is
in the same folder, the renamed files are appended with a number in
parentheses to differentiate them, for instance newfile(1).txt,
newfile(2).txt, and newfile(3).txt.
Here is the referenced link.
This also answers my question on where to start to using windows shell api to do stuff. The answer is here.
Yes it is possible see here http://blog.gadodia.net/stupid-windows-trick-mass-renaming/ I used this to oganized and Number files in mass
I want to rename about 100 classes in my Xcode project. It would be painful to change every filename, then do a search and replace on the name of each class in question.
Is there a better way?
The change in question involves changing a prefix -- think of what Apple would need to do if they decided to rename all the classes in their "NS" framework to start with "MS". Unfortunately, the two caps in question do start some words in the project which are not among the class names in question.
If your version of Xcode is reasonably up-to-date, you can right-click on the symbol name in the editor and choose "Refactor..." which will take care of both renaming files and renaming symbols (with the appropriate checkbox enabled).
If you don't have C++, Shaggy's answer will probably work for you. But in my case, the answer appears to be that there is no better way.
I'm working in XCode and I've also written an external editor tool that generates resources for use in the project. In the best case scenario, the tool would edit the project.pbxproj file so that it includes the generated resources in the project. I've read through the file in an attempt to understand it, and it's mostly discernible but there is still one major question I have.
If I wanted to generate a new Group from outside XCode (or a new anything, for that matter), how do I know what ID code to use? For example: 19C28FACFE9D520D11CA2CBB is one of them from my project. How am I supposed to know what to use if I make my own? Do they just need to be unique? Would it be legal to just make one up: 000000000000000000000001 and 000000000000000000000002 and 000000000000000000000003 etc. ?
Any help on this would be wonderful. Thanks.
Yes, you can make your own. The best way would be to use a hash function such as MD5 or SHA1 to generate it then you can truncate it at the desired length. I would hash the name of the file/group along with a time stamp appended this way you get a more unique result.