PathForResource with wildcard for thefilename parameter - ios

I know this sounds weird, but is it possible to use wildcard for theFileName parameter?
NSBundle.mainBundle().pathForResource(theFileName, ofType: "csv", inDirectory: directory)
Because I have several files that follow particular naming scheme. Basically, the first part of the filename is English and the second part is French. They are separated by three dashes. For example, "West---Ouest.csv". There is REST service the provides English part of the file name. However, it does not provide French. So what I like to do is use the English part and replace the french part with say asterisk. So, the value for filename parameter would be - "West---*". I tested asterisk, but seems that pathforresource does not work with that. Any work around to this problem?
Edit: English part is unique, so there's no file with the same english name.

No, there isn't. This is not a dynamically created file; you put it into your project by hand before building. Its name is absolutely known to you, and you must use its absolute name. Of course, you are free to change its name when you put it into your project. And if you have several files, you are free to form the name dynamically in code when your app runs — after all, theFileName can be created on the fly however you like. For example, in my app I have files called image1.jpg, image2.jpg, and so on, so I start with a number, form the name, and fetch the image.

Related

How to rebrand Chromium in different language than English

I have the following problem. I want to rebrand the Chromium label to my own brand. I have tried this:
How to change Chromium browser logo and name?
so I have tried to replace all occurrences of "Chromium" or "Chrome" in the following files.
src/chrome/app/theme/chromium/BRANDING
src/chrome/app/generated_resources.grd
src/chrome/app/chromium_strings.grd
Now I need the browser to be in another language than English. Compiling the browser, some sections of the UI now have my new brand, but are still written in English, i.e. not translated. I suppose the reason is somewhere, that I have modified the .grd files as these are the template files for the translation. I have also looked into the associated .xtb files. There are the unique numerical ids for the translated string, and I think because I altered the occurences to my own brand in the template, the mapping between the string in the template and the translation in the .xtb file is corrupted.
How can I change the brand as suggested by Asesh in the link above and still have everything properly translated?
I have tried to modify the xtb files with my new brand name as well but the mapping did not work out between the id and the string in the template. I have read about GRIT but if I got it right, I cannot use the grit tool that comes with Chromium to just generate new numerical ids for the translations.

what is url shorthand in a filesystem

This should be pretty simple I need know what dots mean in a url such as "../../../Program Files (x86)/Filed/examples/tmw_desert_spacing.png"
I'm assuming this is some kind of shorthand that means "the same as the current directory"/etc/folder/file.png a link to an article that explains this would be nice too, my google search turned up nothing since im not even sure this is called a url. thanks
more info: the program im writing won't except this as the file name, I need to konw what need to change to become acceptable.
According to RFC 3986:
The path segments "." and "..", also known as dot-segments, are
defined for relative reference within the path name hierarchy. They
are intended for use at the beginning of a relative-path reference
(Section 4.2) to indicate relative position within the hierarchical
tree of names.
The takeaway is that they have the same meaning as in paths on a linux or windows system - single dot means "the directory specified by the preceding part of the path", two dots mean "the parent directory of the directory specified by the preceding part of

Additional path prefix on drupal 7

I have to build a multilingual website where you have to select your continent.
So you can choose America while your are in English but also America in Spanish. Europe in French, but also in English etc.
I have set language detection with path prefix on drupal 7. So my urls are like that domain.com/en/path-alias.
Some contents on my website will be hide for some continent but a lot of content will be the same so I dont want to do a multisite.
I wish to have urls like that domain.com/america/en/path-alias, domain.com/america/es/path-alias or domain.com/europe/fr/path-alias.
I don't find any solution to do that.
The module domain access looks cool but is not exactly what i want cause it works with subdomains while i want path prefix.
EDIT :
Ok i have found the solution of my problem in the drupal API.
This two hooks are exactly what i was looking for hook_url_inbound_alter, hook_url_outbound_alter
You should use this 2 hooks because in hook_url_inbound_alter(&$path, $original_path, $path_language) you tell Drupal what path should it display, and determine from received path that comes in $original_path (ex: region/lang/path) path that Drupal understands as a valid path (ex: lang/path) and override $path with it.
Next we need links from our pages to contain our custom path format, so we'll use hook_url_outbound_alter(&$path, &$options, $original_path) to convert all system paths or aliases generated with url() in your custom path format (generated path for url('lang/path')) will be region/lang/path. In $options array we can modify path prefix, or path language.
This worked for me but path alias dose not working now. This http://localhost/en/australia/node/376 should be http://localhost/en/australia/hotels-resorts
function mymodule_url_inbound_alter(&$path, $original_path, $path_language){
$cluster = 'australia';
$path = str_replace($cluster.'/','',$path);
}
function mymodule_url_outbound_alter(&$path, &$options, $original_path){
$cluster = 'australia';
$path = $cluster.'/'.($path);
$options['alias'] = true;
}

Localizing strings from the Settings.bundle using InAppSettingsKit

I am attempting to use InAppSettingsKit to manage my settings. This uses the Settings.bundle with a .plist file and the .strings files for each of the languages being translated.
I can confirm that the translation of my strings is working properly outside of my application, using the Setting application. But when I am in my application, the translation is not occurring.
I think it comes down to code like this, from the InAppSettingsKit class IASKSettingsReader, with a couple logging statements that I thought my be helpful:
- (NSString*)titleForStringId:(NSString*)stringId {
NSLog(#"%#",[_bundle localizedStringForKey:stringId value:stringId table:self.localizationTable]);
NSLog(#"%#",[_bundle localizedInfoDictionary]);
return [_bundle localizedStringForKey:stringId value:stringId table:self.localizationTable];
}
If I understand correctly, this should be using a table with the name self.localizationTable as the source of the translation. This value is simply "Root". It's not a path to the Root.strings file in the selected language, so I am guessing that the method localizedStringForKey:value:table: must be using some global system reference that points to the correct path.
I have confirmed that the strings file name is "Root.strings" all around, with a capital R, including in the Root.plist file.
[_bundle localizedInfoDictionary] returns (null); It is doing this for two language settings of English and French.
I'm not sure how to debug this. Thanks for any help you can give.
I'm using InAppSettingsKit with localized text with no problems. Two things I can think of that you could check: are your Root.strings files located in the correct subdirectories of Settings.bundle (en.lproj and fr.lproj for English and French?
Is there a "Strings Filename" entry in your Root.plist? It should simply contain a string with value "Root"
It has been quite some time since I resolved this, and at the time, I didn't fully understand it. But, in the interest of closing out this question, I'll point to the following documentation for future reference:
NSBundle Class Reference
which refers to the following:
Resource Programming Guide
In the second document, refer to the section "String REsources -> Loading String Resources Into Your Code"
The solution contains a properly configured Root.strings file, which shows up in the file list like this:

Deleting a temporary directory

I have this code,
showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID);
if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then
showmessage('Removed')
else
showmessage('Failed');
The message shows C:\TEMP\0 and this directory does exist as the program created it earlier and used files inside it and then later deletes them. I can see the files and directories so I know they're there. The program successfully deletes the files but does not remove the directory.
If I hardcode the directory it works - this means that it accepts the string
C:\TEMP\0 but does not accept C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID both equate to C:\TEMP\0. I cannot hardcode these directories, so what can I do? How do I convert from a string + string to whatever removedir() is expecting. I looked this up at Delphi basics and it's expecting a string.
I'm confused, since string + string = string. What is going on?
Make sure that neither your program nor any other program have the directory as their current working directory. When you recompile the program this may no longer be the case, so it may be a red herring that the hardcoded value works for you.
In addition to the other good answers, you should not be storing your temp folder in C:\TEMP. Use the value returned from GetTempFilename, instead. Unlike C:\TEMP, this location (which varies by operating system) will work on all operating systems, and all levels of user access control. This also eliminates the risk that the location you have hardcoded might also be hardcoded into another system.
If I understood correctly, openfiles[openfilelist.ItemIndex].ID is a string that contains number?
If so, did you check that it does not contain blanks? Something like this:
filename := 'C:\TEMP\' + trim(openfiles[openfilelist.ItemIndex].ID);
showmessage(filename);
if removedir(filename) then
showmessage('Removed')
else
showmessage('Failed');
What type of objects are openfiles and openfilelist?
Do they open folders at all, if so they may still be open when your trying to delete the folder.

Resources