mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-11-01 01:21:18 +01:00 
			
		
		
		
	# Description of Changes - **What was changed:** - Renamed top-level directories: `stirling-pdf` → `app/core`, `common` → `app/common`, `proprietary` → `app/proprietary`. - Updated all path references in `.gitattributes`, GitHub workflows (`.github/workflows/*`), scripts (`.github/scripts/*`), `.gitignore`, Dockerfiles, license files, and template settings to reflect the new structure. - Added a new CI job `check-generateOpenApiDocs` to generate and upload OpenAPI documentation. - Removed redundant `@Autowired` annotations from `TempFileShutdownHook` and `UnlockPDFFormsController`. - Minor formatting and comment adjustments in YAML templates and resource files. - **Why the change was made:** - To introduce a clear `app/` directory hierarchy for core, common, and proprietary modules, improving organization and maintainability. - To ensure continuous integration and Docker builds continue to work seamlessly with the reorganized structure. - To automate OpenAPI documentation generation as part of the CI pipeline. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
		
			
				
	
	
		
			81 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
package stirling.software.Stirling.Stats;
 | 
						|
 | 
						|
import java.nio.file.*;
 | 
						|
import java.nio.charset.MalformedInputException;
 | 
						|
import java.nio.charset.StandardCharsets;
 | 
						|
import java.io.*;
 | 
						|
import java.util.*;
 | 
						|
 | 
						|
public class PropSync {
 | 
						|
 | 
						|
    public static void main(String[] args) throws IOException {
 | 
						|
        File folder = new File("C:\\Users\\systo\\git\\Stirling-PDF\\app\\core\\src\\main\\resources");
 | 
						|
        File[] files = folder.listFiles((dir, name) -> name.matches("messages_.*\\.properties"));
 | 
						|
 | 
						|
        List<String> enLines = Files.readAllLines(Paths.get(folder + "\\messages_en_GB.properties"), StandardCharsets.UTF_8);
 | 
						|
        Map<String, String> enProps = linesToProps(enLines);
 | 
						|
 | 
						|
        for (File file : files) {
 | 
						|
            if (!"messages_en_GB.properties".equals(file.getName())) {
 | 
						|
                System.out.println("Processing file: " + file.getName());
 | 
						|
                List<String> lines;
 | 
						|
                try {
 | 
						|
                    lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
 | 
						|
                } catch (MalformedInputException e) {
 | 
						|
                    System.out.println("Skipping due to not UTF8 format for file: " + file.getName());
 | 
						|
                    continue;
 | 
						|
                } catch (IOException e) {
 | 
						|
                    throw new UncheckedIOException(e);
 | 
						|
                }
 | 
						|
 | 
						|
                Map<String, String> currentProps = linesToProps(lines);
 | 
						|
                List<String> newLines = syncPropsWithLines(enProps, currentProps, enLines);
 | 
						|
 | 
						|
                Files.write(file.toPath(), newLines, StandardCharsets.UTF_8);
 | 
						|
                System.out.println("Finished processing file: " + file.getName());
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    private static Map<String, String> linesToProps(List<String> lines) {
 | 
						|
        Map<String, String> props = new LinkedHashMap<>();
 | 
						|
        for (String line : lines) {
 | 
						|
            if (!line.trim().isEmpty() && line.contains("=")) {
 | 
						|
                String[] parts = line.split("=", 2);
 | 
						|
                props.put(parts[0].trim(), parts[1].trim());
 | 
						|
            }
 | 
						|
        }
 | 
						|
        return props;
 | 
						|
    }
 | 
						|
 | 
						|
    private static List<String> syncPropsWithLines(Map<String, String> enProps, Map<String, String> currentProps, List<String> enLines) {
 | 
						|
        List<String> newLines = new ArrayList<>();
 | 
						|
        boolean needsTranslateComment = false; // flag to check if we need to add "TODO: Translate"
 | 
						|
 | 
						|
        for (String line : enLines) {
 | 
						|
            if (line.contains("=")) {
 | 
						|
                String key = line.split("=", 2)[0].trim();
 | 
						|
 | 
						|
                if (currentProps.containsKey(key)) {
 | 
						|
                    newLines.add(key + "=" + currentProps.get(key));
 | 
						|
                    needsTranslateComment = false;
 | 
						|
                } else {
 | 
						|
                    if (!needsTranslateComment) {
 | 
						|
                        newLines.add("##########################");
 | 
						|
                        newLines.add("###  TODO: Translate   ###");
 | 
						|
                        newLines.add("##########################");
 | 
						|
                        needsTranslateComment = true;
 | 
						|
                    }
 | 
						|
                    newLines.add(line);
 | 
						|
                }
 | 
						|
            } else {
 | 
						|
                // handle comments and other non-property lines
 | 
						|
                newLines.add(line);
 | 
						|
                needsTranslateComment = false;  // reset the flag when we encounter comments or empty lines
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        return newLines;
 | 
						|
    }
 | 
						|
}
 |