private bool checkWantAddResourceFile( ZlpFileInfo filePath) { if (filePath == null) { return(false); } else { if (filePath.Directory.Name.EqualsNoCase(@"Properties")) { return(true); } else { // If a "*.Designer.*" companion file exists, assume it // is a Windows Forms resource file and do NOT add the file // since it can be translated directly from within VS.NET. if (Project.IgnoreWindowsFormsResourcesWithDesignerFiles) { var baseFileName = LanguageCodeDetection.GetBaseName(Project, filePath.Name); var files = filePath.Directory.GetFiles($@"{baseFileName}.Designer.*"); return(files.Length <= 0); } else { return(true); } } } }
private bool checkWantAddResourceFile( ZlpFileInfo filePath) { if (filePath == null) { return(false); } else { if (string.Compare(@"Properties", filePath.Directory.Name, StringComparison.OrdinalIgnoreCase) == 0) { return(true); } else { // If a "*.Designer.*" companion file exists, assume it // is a Windows Forms resource file and do NOT add the file // since it can be translated directly from within VS.NET. if (Project.IgnoreWindowsFormsResourcesWithDesignerFiles) { var baseFileName = LanguageCodeDetection.GetBaseName( Project, filePath.Name); //filePath.Name.Substring(0, filePath.Name.IndexOf('.')); var files = filePath.Directory.GetFiles( string.Format(@"{0}.Designer.*", baseFileName)); return(files.Length <= 0); } else { return(true); } } } }
public string GetNameIntelligent( Project project) { lock (_fileInfos) { if (string.IsNullOrEmpty(_name) && _fileInfos.Count > 0) { // Try guessing several names. var filePath = _fileInfos[0].File; var folderPath = filePath.Directory; //CHANGED: use base name instead var baseName = LanguageCodeDetection.GetBaseName(project, filePath.Name); filePath = new ZlpFileInfo(ZlpPathHelper.Combine(folderPath.FullName, baseName)); if ((string.Equals(@"Properties", folderPath.Name, StringComparison.InvariantCultureIgnoreCase) || string.Equals(@"App_GlobalResources", folderPath.Name, StringComparison.InvariantCultureIgnoreCase)) && filePath.Name.StartsWith( @"Resources.", StringComparison.InvariantCultureIgnoreCase)) { var parentFolderPath = folderPath.Parent; if (parentFolderPath == null) { return(_name); } else { //CHANGED: append fileName, otherwise name is not complete. var pathToMakeRelative = ZlpPathHelper.Combine(parentFolderPath.FullName, filePath.Name); return (shortenFilePath( ZlpPathHelper.GetRelativePath( project == null ? string.Empty : project.ProjectConfigurationFilePath.DirectoryName, pathToMakeRelative))); } } else if (string.Equals(@"App_LocalResources", folderPath.Name, StringComparison.InvariantCultureIgnoreCase)) { var name = ZlpPathHelper.GetRelativePath( project == null ? string.Empty : project.ProjectConfigurationFilePath.DirectoryName, filePath.FullName); var ext = ZlpPathHelper.GetExtension(name); var result = name.Substring(0, name.Length - ext.Length); return(shortenFilePath(result)); } else { return (shortenFilePath( ZlpPathHelper.GetRelativePath( project == null ? string.Empty : project.ProjectConfigurationFilePath.DirectoryName, filePath.FullName))); } } else { return(_name); } } }
// ADDED: adds resources from file Info lists. // I have changed a method doAutomaticallyAddResourceFiles to fill file groups. // You can use same method if you call this method from there. // ATTENTION: LanguageCodeDetection was modified a bit to support variable amount // of point in base name. New method GetBaseName(IInheritedSettings settings, string fileName) // was added to get same base name FileGroup gets. public void DoAutomaticallyAddResourceFilesFromList( BackgroundWorker backgroundWorker, ProjectFolder parentProjectFolder, ref int fileGroupCount, ref int fileCount, ICollection <ZlpFileInfo> fileList) { if (backgroundWorker.CancellationPending) { throw new OperationCanceledException(); } else if (fileList != null && fileList.Count > 0) { var fileGroups = Project.FileGroups; //if (parentProjectFolder != null) //{ // fileGroups = parentProjectFolder.ChildFileGroups; //} foreach (var filePath in fileList) { if (backgroundWorker.CancellationPending) { throw new OperationCanceledException(); } //other algorithm to determine base name to allow multiple points inside name var baseFileName = LanguageCodeDetection.GetBaseName(Project, filePath.Name); var wantAddResourceFile = checkWantAddResourceFile(filePath); if (wantAddResourceFile) { //find right file group var path = filePath; var fileGroup = fileGroups.Find( g => string.Compare(g.BaseName, baseFileName, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(g.FolderPath.FullName, path.Directory.FullName, StringComparison.OrdinalIgnoreCase) == 0); if (fileGroup == null) { fileGroup = new FileGroup(Project) { ProjectFolder = parentProjectFolder }; // Look for same entries. if (!Project.FileGroups.HasFileGroupWithChecksum( fileGroup.GetChecksum(Project))) { fileGroups.Add(fileGroup); fileGroupCount++; } } fileGroup.Add( new FileInformation(fileGroup) { File = filePath }); fileCount++; } } } }